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