epoc32/include/mw/prnsetup.h
branchSymbian2
changeset 3 e1b950c65cb4
parent 2 2fe1408b6811
child 4 837f303aceeb
equal deleted inserted replaced
2:2fe1408b6811 3:e1b950c65cb4
       
     1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // 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
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef __PRNSETUP_H__
       
    17 #define __PRNSETUP_H__
       
    18 
       
    19 #if !defined(__E32STD_H__)
       
    20 #include <e32std.h>
       
    21 #endif
       
    22 #if !defined(__E32BASE_H__)
       
    23 #include <e32base.h>
       
    24 #endif
       
    25 #if !defined(__FLDBLTIN_H__)
       
    26 #include <fldbltin.h>
       
    27 #endif
       
    28 #if !defined(__PRNINF_H__)
       
    29 #include <prninf.h>
       
    30 #endif
       
    31 
       
    32 /** @publishedPartner */
       
    33 const TInt KErrMorePages=4747; // Leave with this error code to print extra pages in PrintBandL
       
    34 
       
    35 /** @internalTechnology */
       
    36 _LIT( KDefaultPrinterDriverPath, "\\resource\\printers\\" );
       
    37 
       
    38 // Classes defined //
       
    39 class CPrintSetup;
       
    40 //
       
    41 
       
    42 // Forward Reference
       
    43 class CPreviewProcess;
       
    44 class CPrintProcess;
       
    45 class CPdrModelList;
       
    46 class CPdrDevice;
       
    47 class CHeaderFooter;
       
    48 class TPageSpec;
       
    49 class RReadStream;
       
    50 class RWriteStream;
       
    51 class MPageRegionPrinter;
       
    52 class RFs;
       
    53 class CPrinterDriver;
       
    54 class CPrinterDriverUI;
       
    55 //
       
    56 
       
    57 class CPrintSetup : public CBase, private MFieldPageNumInfo
       
    58 /** Print setup information.
       
    59 
       
    60 This class stores the information needed to set up, start and stop a print 
       
    61 job. This includes the target printer device, the page margins and 
       
    62 the header and footer. The page specification, (page orientation and page 
       
    63 dimensions) can be set via the printer device.
       
    64 
       
    65 Print setup information is associated with a document and is stored as part 
       
    66 of the persistent form of the document. Print parameters on the other hand, 
       
    67 (class TPrintParameters) are associated with a particular print request, 
       
    68 not with the document itself, so are not part of the print setup information. 
       
    69 
       
    70 @publishedAll
       
    71 @released */
       
    72 	{
       
    73 public:
       
    74 	IMPORT_C static CPrintSetup* NewL();
       
    75 	IMPORT_C virtual ~CPrintSetup();
       
    76 	//
       
    77 	// printer model selection/control functions
       
    78 	IMPORT_C void AddPrinterDriverDirL(const TDesC& aDriverDir);
       
    79 	IMPORT_C CPrinterModelList* ModelNameListL(RFs& aFs);
       
    80 	IMPORT_C void FreeModelList();
       
    81 	IMPORT_C void CreatePrinterDeviceL(TInt aModelIndex); // requires ModelList to exist
       
    82 	IMPORT_C void CreatePrinterDeviceL(TUid aModelUid,RFs& aFs);
       
    83 	IMPORT_C CPrinterDevice* PrinterDevice()const;
       
    84 	IMPORT_C CPrinterDriverUI* CreatePrinterDriverUIL(); // ownership is transfered to the caller
       
    85 	//
       
    86 	// print functions
       
    87 	IMPORT_C void EndPrint();
       
    88 	IMPORT_C TInt StartPrintL(const TPrintParameters& aPrintParams,MPageRegionPrinter& aBodyPrinter,
       
    89 				CPrinterPort* aPort,MPrintProcessObserver* anObserver);
       
    90 	IMPORT_C TInt StartPreviewPrintL(const TPrintParameters& aPrintParams,MPageRegionPrinter& aBodyPrinter,
       
    91 				MPrintProcessObserver* anObserver,CGraphicsDevice& aPreviewDev,const TRect& aHeaderRectInPixels,
       
    92 				const TRect& aFooterRectInPixels,TInt aNumBands);
       
    93 	//
       
    94 	// accessors
       
    95 	inline CHeaderFooter* Header()const;
       
    96 	inline CHeaderFooter* Footer()const;
       
    97 	//
       
    98 	// persistence
       
    99 	IMPORT_C TStreamId StoreL(CStreamStore& aStore)const;
       
   100 	IMPORT_C void RestoreL(const CStreamStore& aStore,TStreamId aStreamId,const MFieldFileNameInfo* aFileNameInfo=NULL,const MFieldNumPagesInfo* aNumPagesInfo=NULL,MPictureFactory* aFactory=NULL);
       
   101 	IMPORT_C void StoreComponentsL(CStreamStore& aStore,CStoreMap& aMap)const;
       
   102 	IMPORT_C void RestoreComponentsL(const CStreamStore& aStore,const MFieldFileNameInfo* aFileNameInfo=NULL,const MFieldNumPagesInfo* aNumPagesInfo=NULL,MPictureFactory* aFactory=NULL);
       
   103 	IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
       
   104 	IMPORT_C void InternalizeL(RReadStream& aStream);
       
   105 	//
       
   106 private:
       
   107 	CPrintSetup();
       
   108 	void ConstructL();
       
   109 	void DoStartPrintL(const TPrintParameters& aPrintParams,MPageRegionPrinter& aBodyPrinter,MPrintProcessObserver* aObserver,CPrinterPort* aPort);
       
   110 	void InitializePrintingL(CGraphicsDevice* aPrinterDev,const TPrintParameters& aPrintParams,MPrintProcessObserver* aObserver);
       
   111 	void InitializePrintingL(const TPrintParameters& aPrintParams,MPrintProcessObserver* aObserver,
       
   112 									 const TRect& aHeaderRectInPixels,const TRect& aFooterRectInPixels);
       
   113 	// from MFieldPageNumInfo
       
   114 	TInt UpdateFieldPageNum()const;
       
   115 public:
       
   116 	// Info regarding print setup etc.
       
   117 	/** The header and footer offset and the width of the four margins. 
       
   118 	
       
   119 	All measurements are in twips.
       
   120 	
       
   121 	@see TPageMargins */
       
   122 	TPageMargins iPageMarginsInTwips;
       
   123 	/** The number of the first page in the document.
       
   124 	
       
   125 	This value is used for printing or displaying page numbering. Note that all 
       
   126 	other page numbering is zero indexed, to preserve independence from user-defined 
       
   127 	page numbering. */
       
   128 	TInt iNumOfFirstPage; // value to start page numbering at
       
   129 private:
       
   130 	enum {
       
   131 		ENumberFirstPage = 0x0001,
       
   132 		};
       
   133 private:
       
   134 	CHeaderFooter* iHeader;
       
   135 	CHeaderFooter* iFooter;
       
   136 	CPrinterDriver* iPrinterDriver; // the target printer driver
       
   137 	CPreviewProcess* iPrintProcess;
       
   138 	CPdrModelList* iModelList;
       
   139 	MPrintProcessObserver* iPrintObserver;
       
   140 	TPrintParameters iPrintParams; // not persisted
       
   141 	CArrayFixSeg<TFileName>* iDriverDirList;
       
   142 	};
       
   143 
       
   144 
       
   145 //
       
   146 // inlines
       
   147 //
       
   148 
       
   149 inline CHeaderFooter* CPrintSetup::Header()const
       
   150 /** Gets the header.
       
   151 
       
   152 The CPrintSetup object owns the header and footer. CPrintSetup implements 
       
   153 the MFieldPageNumInfo interface, which allows page numbering to be easily 
       
   154 added to fields.
       
   155 
       
   156 @return The header. */
       
   157 	{ return iHeader; }
       
   158 
       
   159 inline CHeaderFooter* CPrintSetup::Footer()const
       
   160 /** Gets the footer.
       
   161 
       
   162 @return The footer. */
       
   163 	{ return iFooter; }
       
   164 
       
   165 
       
   166 
       
   167 
       
   168 #endif