os/graphics/printingservices/printerdriversupport/src/METAFILE.CPP
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#include <metafile.h>
sl@0
    17
#include <bitdev.h>
sl@0
    18
#include <fbs.h>
sl@0
    19
sl@0
    20
NONSHARABLE_CLASS(CFontStack) : public CBase
sl@0
    21
	{
sl@0
    22
protected:
sl@0
    23
	CFontStack(CGraphicsDevice* aDevice);
sl@0
    24
public:
sl@0
    25
	static CFontStack* NewL(CGraphicsDevice* aDevice);
sl@0
    26
	~CFontStack();
sl@0
    27
	void AddFontL(CFont* aFont);
sl@0
    28
private:
sl@0
    29
	CGraphicsDevice* iDevice;
sl@0
    30
	CArrayPtrFlat<CFont>* iFontList;
sl@0
    31
	};
sl@0
    32
sl@0
    33
CFontStack::CFontStack(CGraphicsDevice* aDevice):
sl@0
    34
	iDevice(aDevice),
sl@0
    35
	iFontList(NULL)
sl@0
    36
	{
sl@0
    37
	__DECLARE_NAME(_S("CFontStack"));
sl@0
    38
	}
sl@0
    39
sl@0
    40
CFontStack* CFontStack::NewL(CGraphicsDevice* aDevice)
sl@0
    41
	{
sl@0
    42
	CFontStack* fontstack=new(ELeave) CFontStack(aDevice);
sl@0
    43
	CleanupStack::PushL(fontstack);
sl@0
    44
	fontstack->iFontList=new(ELeave) CArrayPtrFlat<CFont>(8);
sl@0
    45
	CleanupStack::Pop();
sl@0
    46
	return fontstack;
sl@0
    47
	}
sl@0
    48
sl@0
    49
CFontStack::~CFontStack()
sl@0
    50
	{
sl@0
    51
	if (iFontList)
sl@0
    52
		{
sl@0
    53
		TInt count=iFontList->Count();
sl@0
    54
		for (TInt i=0; i<count; i++)
sl@0
    55
			iDevice->ReleaseFont((*iFontList)[i]);
sl@0
    56
		delete iFontList;
sl@0
    57
		}
sl@0
    58
	}
sl@0
    59
sl@0
    60
void CFontStack::AddFontL(CFont* aFont)
sl@0
    61
	{
sl@0
    62
	TRAPD(ret,iFontList->AppendL(aFont));
sl@0
    63
	if (ret!=KErrNone)
sl@0
    64
		{
sl@0
    65
		iDevice->ReleaseFont(aFont);
sl@0
    66
		User::Leave(ret);
sl@0
    67
		}
sl@0
    68
	}
sl@0
    69
sl@0
    70
enum TGraphicsContextCommandCode
sl@0
    71
	{
sl@0
    72
	EUseGc,     //  Not gc command
sl@0
    73
	EEndOfStream,
sl@0
    74
sl@0
    75
	ESetOrigin,
sl@0
    76
	ESetDrawMode,
sl@0
    77
	ESetClippingRect,
sl@0
    78
	ECancelClippingRect,
sl@0
    79
	EReset,
sl@0
    80
	EUseFont,
sl@0
    81
	EDiscardFont,
sl@0
    82
	ESetUnderlineStyle,
sl@0
    83
	ESetStrikethroughStyle,
sl@0
    84
	ESetWordJustification,
sl@0
    85
	ESetCharJustification,
sl@0
    86
	ESetPenColor,
sl@0
    87
	ESetPenStyle,
sl@0
    88
	ESetPenSize,
sl@0
    89
	ESetBrushColor,
sl@0
    90
	ESetBrushStyle,
sl@0
    91
	ESetBrushOrigin,
sl@0
    92
	EUseBrushPattern,
sl@0
    93
	EDiscardBrushPattern,
sl@0
    94
	EMoveTo,
sl@0
    95
	EMoveBy,
sl@0
    96
	EPlot,
sl@0
    97
	EDrawArc,
sl@0
    98
	EDrawLine,
sl@0
    99
	EDrawLineTo,
sl@0
   100
	EDrawLineBy,
sl@0
   101
	EDrawPolyLine1, 
sl@0
   102
	EDrawPolyLine2, 
sl@0
   103
	EDrawPie,
sl@0
   104
	EDrawEllipse,
sl@0
   105
	EDrawRect,
sl@0
   106
	EDrawRoundRect,
sl@0
   107
	EDrawPolygon1,  
sl@0
   108
	EDrawPolygon2,  
sl@0
   109
	EDrawBitmap1,   
sl@0
   110
	EDrawBitmap2,   
sl@0
   111
	EDrawBitmap3,   
sl@0
   112
	EDrawText1,	   
sl@0
   113
	EDrawText2	   
sl@0
   114
	};
sl@0
   115
sl@0
   116
inline RWriteStream& operator<<(RWriteStream& aStream,TGraphicsContextCommandCode aCommandCode)
sl@0
   117
	{
sl@0
   118
	aStream.WriteUint8L(TUint8(aCommandCode));
sl@0
   119
	return aStream;
sl@0
   120
	}
sl@0
   121
sl@0
   122
EXPORT_C CMetafileDevice::CMetafileDevice(CGraphicsDevice* aDevice):
sl@0
   123
	CGraphicsDevice(),
sl@0
   124
	iGcCount(0),
sl@0
   125
	iGcIndex(-1),
sl@0
   126
	iRealDevice(aDevice),
sl@0
   127
	iWriteStream(NULL)
sl@0
   128
	{
sl@0
   129
	__DECLARE_NAME(_S("CMetafileDevice"));
sl@0
   130
	}
sl@0
   131
sl@0
   132
EXPORT_C CMetafileDevice* CMetafileDevice::NewL(CGraphicsDevice* aDevice)
sl@0
   133
	{
sl@0
   134
	CMetafileDevice* device=new(ELeave) CMetafileDevice(aDevice);	
sl@0
   135
	return device;
sl@0
   136
	}
sl@0
   137
sl@0
   138
EXPORT_C CMetafileDevice::~CMetafileDevice()
sl@0
   139
	{
sl@0
   140
	}
sl@0
   141
sl@0
   142
EXPORT_C TInt CMetafileDevice::HorizontalTwipsToPixels(TInt aTwips) const
sl@0
   143
	{
sl@0
   144
	return iRealDevice->HorizontalTwipsToPixels(aTwips);
sl@0
   145
	}
sl@0
   146
sl@0
   147
EXPORT_C TInt CMetafileDevice::VerticalTwipsToPixels(TInt aTwips) const
sl@0
   148
	{
sl@0
   149
	return iRealDevice->VerticalTwipsToPixels(aTwips);
sl@0
   150
	}
sl@0
   151
sl@0
   152
EXPORT_C TInt CMetafileDevice::HorizontalPixelsToTwips(TInt aPixels) const
sl@0
   153
	{
sl@0
   154
	return iRealDevice->HorizontalPixelsToTwips(aPixels);
sl@0
   155
	}
sl@0
   156
sl@0
   157
EXPORT_C TInt CMetafileDevice::VerticalPixelsToTwips(TInt aPixels) const
sl@0
   158
	{
sl@0
   159
	return iRealDevice->VerticalPixelsToTwips(aPixels);
sl@0
   160
	}
sl@0
   161
sl@0
   162
EXPORT_C TInt CMetafileDevice::GetNearestFontInTwips(CFont*& aFont,const TFontSpec& aFontSpec)
sl@0
   163
	{
sl@0
   164
	return GetNearestFontToDesignHeightInTwips(aFont, aFontSpec);
sl@0
   165
	}
sl@0
   166
sl@0
   167
EXPORT_C TInt CMetafileDevice::GetNearestFontToDesignHeightInTwips(CFont*& aFont,const TFontSpec& aFontSpec)
sl@0
   168
	{
sl@0
   169
	return iRealDevice->GetNearestFontToDesignHeightInTwips(aFont,aFontSpec);
sl@0
   170
	}
sl@0
   171
sl@0
   172
EXPORT_C TInt CMetafileDevice::GetNearestFontToMaxHeightInTwips(CFont*& aFont,const TFontSpec& aFontSpec, TInt aMaxHeight)
sl@0
   173
	{
sl@0
   174
	return iRealDevice->GetNearestFontToMaxHeightInTwips(aFont, aFontSpec, aMaxHeight);
sl@0
   175
	}
sl@0
   176
sl@0
   177
EXPORT_C void CMetafileDevice::ReleaseFont(CFont* aFont)
sl@0
   178
	{
sl@0
   179
	iRealDevice->ReleaseFont(aFont);
sl@0
   180
	}					
sl@0
   181
sl@0
   182
EXPORT_C TDisplayMode CMetafileDevice::DisplayMode() const
sl@0
   183
	{
sl@0
   184
	return iRealDevice->DisplayMode();
sl@0
   185
	}
sl@0
   186
sl@0
   187
EXPORT_C TSize CMetafileDevice::SizeInPixels() const
sl@0
   188
	{
sl@0
   189
	return iRealDevice->SizeInPixels();
sl@0
   190
	}
sl@0
   191
sl@0
   192
EXPORT_C TSize CMetafileDevice::SizeInTwips() const
sl@0
   193
	{
sl@0
   194
	return iRealDevice->SizeInTwips();
sl@0
   195
	}
sl@0
   196
sl@0
   197
EXPORT_C TInt CMetafileDevice::CreateContext(CGraphicsContext*& aGC)
sl@0
   198
	{
sl@0
   199
	CMetafileGc* gc=new CMetafileGc(this,iGcCount);
sl@0
   200
	if (!gc)
sl@0
   201
		return KErrNoMemory;
sl@0
   202
	iGcCount++;
sl@0
   203
	aGC=gc;
sl@0
   204
	return KErrNone;
sl@0
   205
	}
sl@0
   206
sl@0
   207
EXPORT_C TInt CMetafileDevice::NumTypefaces() const
sl@0
   208
	{
sl@0
   209
	return iRealDevice->NumTypefaces();
sl@0
   210
	}
sl@0
   211
sl@0
   212
EXPORT_C void CMetafileDevice::TypefaceSupport(TTypefaceSupport& aTypefaceSupport,TInt aTypefaceIndex) const
sl@0
   213
	{
sl@0
   214
	iRealDevice->TypefaceSupport(aTypefaceSupport,aTypefaceIndex);
sl@0
   215
	}
sl@0
   216
sl@0
   217
EXPORT_C TInt CMetafileDevice::FontHeightInTwips(TInt aTypefaceIndex,TInt aHeightIndex) const
sl@0
   218
	{
sl@0
   219
	return iRealDevice->FontHeightInTwips(aTypefaceIndex,aHeightIndex);
sl@0
   220
	}
sl@0
   221
sl@0
   222
EXPORT_C void CMetafileDevice::PaletteAttributes(TBool& aModifiable,TInt& aNumEntries) const
sl@0
   223
	{
sl@0
   224
	iRealDevice->PaletteAttributes(aModifiable,aNumEntries);
sl@0
   225
	}
sl@0
   226
sl@0
   227
EXPORT_C void CMetafileDevice::SetPalette(CPalette* aPalette)
sl@0
   228
	{
sl@0
   229
	iRealDevice->SetPalette(aPalette);
sl@0
   230
	}
sl@0
   231
sl@0
   232
EXPORT_C TInt CMetafileDevice::GetPalette(CPalette*& aPalette) const
sl@0
   233
	{
sl@0
   234
	return iRealDevice->GetPalette(aPalette);
sl@0
   235
	}
sl@0
   236
sl@0
   237
EXPORT_C void CMetafileDevice::UseGcL(TInt aGcIndex)
sl@0
   238
	{
sl@0
   239
	if (iGcIndex!=aGcIndex)
sl@0
   240
		{
sl@0
   241
		iGcIndex=aGcIndex;
sl@0
   242
		*iWriteStream << EUseGc;
sl@0
   243
		iWriteStream->WriteInt32L(iGcIndex);
sl@0
   244
		}
sl@0
   245
	}
sl@0
   246
sl@0
   247
EXPORT_C void CMetafileDevice::StartOutputStreamL(RWriteStream& aStream)  // Returns error code
sl@0
   248
	{
sl@0
   249
	iWriteStream=&aStream;
sl@0
   250
	TSize size(HorizontalPixelsToTwips(1000),VerticalPixelsToTwips(1000));
sl@0
   251
	*iWriteStream << size;
sl@0
   252
	}
sl@0
   253
sl@0
   254
EXPORT_C void CMetafileDevice::EndOfStreamL()  // Returns error code
sl@0
   255
	{
sl@0
   256
	*iWriteStream << EEndOfStream;
sl@0
   257
	}
sl@0
   258
sl@0
   259
EXPORT_C RWriteStream& CMetafileDevice::WriteStream()
sl@0
   260
	{
sl@0
   261
	return *iWriteStream;
sl@0
   262
	}
sl@0
   263
sl@0
   264
EXPORT_C CMetafileGc::CMetafileGc(CMetafileDevice* aDevice,TInt anIndex):
sl@0
   265
	CGraphicsContext(),
sl@0
   266
	iDevice(aDevice),
sl@0
   267
	iIndex(anIndex)
sl@0
   268
	{
sl@0
   269
	}
sl@0
   270
sl@0
   271
EXPORT_C CMetafileGc::~CMetafileGc()
sl@0
   272
	{
sl@0
   273
	}
sl@0
   274
sl@0
   275
EXPORT_C CGraphicsDevice* CMetafileGc::Device() const
sl@0
   276
	{
sl@0
   277
	return iDevice;
sl@0
   278
	}
sl@0
   279
sl@0
   280
EXPORT_C void CMetafileGc::SetOrigin(const TPoint& aPos)
sl@0
   281
	{
sl@0
   282
	// TRAP and ignore the ERROR code due to this beeing a non-leaving method
sl@0
   283
	TRAP_IGNORE(iDevice->UseGcL(iIndex));
sl@0
   284
	iDevice->WriteStream() << ESetOrigin;
sl@0
   285
	iDevice->WriteStream() << aPos;
sl@0
   286
	}
sl@0
   287
sl@0
   288
EXPORT_C void CMetafileGc::SetDrawMode(TDrawMode aDrawingMode)
sl@0
   289
	{
sl@0
   290
	TInt	errCode = 0;
sl@0
   291
	// TRAP and ignore the ERROR code due to this beeing a non-leaving method
sl@0
   292
	TRAP_IGNORE(iDevice->UseGcL(iIndex));
sl@0
   293
	iDevice->WriteStream() << ESetDrawMode;
sl@0
   294
	TRAP(errCode, iDevice->WriteStream().WriteUint8L((TUint8) aDrawingMode));
sl@0
   295
	}
sl@0
   296
sl@0
   297
EXPORT_C void CMetafileGc::SetClippingRect(const TRect& aRect)
sl@0
   298
	{
sl@0
   299
	// TRAP and ignore the ERROR code due to this beeing a non-leaving method
sl@0
   300
	TRAP_IGNORE(iDevice->UseGcL(iIndex));
sl@0
   301
	iDevice->WriteStream() << ESetClippingRect;
sl@0
   302
	iDevice->WriteStream() << aRect;
sl@0
   303
	}
sl@0
   304
sl@0
   305
EXPORT_C void CMetafileGc::CancelClippingRect()
sl@0
   306
	{
sl@0
   307
	// TRAP and ignore the ERROR code due to this beeing a non-leaving method
sl@0
   308
	TRAP_IGNORE(iDevice->UseGcL(iIndex));
sl@0
   309
	iDevice->WriteStream() << ECancelClippingRect;
sl@0
   310
	}
sl@0
   311
sl@0
   312
EXPORT_C void CMetafileGc::Reset()
sl@0
   313
	{
sl@0
   314
	// TRAP and ignore the ERROR code due to this beeing a non-leaving method
sl@0
   315
	TRAP_IGNORE(iDevice->UseGcL(iIndex));
sl@0
   316
	iDevice->WriteStream() << EReset;
sl@0
   317
	}
sl@0
   318
sl@0
   319
EXPORT_C void CMetafileGc::UseFont(const CFont* aFont)
sl@0
   320
	{
sl@0
   321
	// TRAP and ignore the ERROR code due to this beeing a non-leaving method
sl@0
   322
	TInt	errCode = 0;
sl@0
   323
	TRAP(errCode, iDevice->UseGcL(iIndex));
sl@0
   324
	iDevice->WriteStream() << EUseFont;
sl@0
   325
	iDevice->WriteStream() << aFont->FontSpecInTwips();
sl@0
   326
	TRAP(errCode, iDevice->WriteStream().WriteInt32L(aFont->HeightInPixels()));
sl@0
   327
	TRAP(errCode, iDevice->WriteStream().WriteInt32L(aFont->BaselineOffsetInPixels()));
sl@0
   328
	}
sl@0
   329
sl@0
   330
EXPORT_C void CMetafileGc::DiscardFont()
sl@0
   331
	{
sl@0
   332
	// TRAP and ignore the ERROR code due to this beeing a non-leaving method
sl@0
   333
	TRAP_IGNORE(iDevice->UseGcL(iIndex));
sl@0
   334
	iDevice->WriteStream() << EDiscardFont;
sl@0
   335
	}
sl@0
   336
sl@0
   337
EXPORT_C void CMetafileGc::SetUnderlineStyle(TFontUnderline aUnderlineStyle)
sl@0
   338
	{
sl@0
   339
	// TRAP and ignore the ERROR code due to this beeing a non-leaving method
sl@0
   340
	TInt	errCode = 0;
sl@0
   341
	TRAP(errCode, iDevice->UseGcL(iIndex));
sl@0
   342
	iDevice->WriteStream() << ESetUnderlineStyle;
sl@0
   343
	TRAP(errCode, iDevice->WriteStream().WriteUint8L((TUint8) aUnderlineStyle));
sl@0
   344
	}
sl@0
   345
sl@0
   346
EXPORT_C void CMetafileGc::SetStrikethroughStyle(TFontStrikethrough aStrikethroughStyle)
sl@0
   347
	{
sl@0
   348
	// TRAP and ignore the ERROR code due to this beeing a non-leaving method
sl@0
   349
	TInt	errCode = 0;
sl@0
   350
	TRAP(errCode, iDevice->UseGcL(iIndex));
sl@0
   351
	iDevice->WriteStream() << ESetStrikethroughStyle;
sl@0
   352
	TRAP(errCode, iDevice->WriteStream().WriteUint8L((TUint8) aStrikethroughStyle));
sl@0
   353
	}
sl@0
   354
sl@0
   355
EXPORT_C void CMetafileGc::SetWordJustification(TInt aExcessWidth,TInt aNumGaps)
sl@0
   356
	{
sl@0
   357
	// TRAP and ignore the ERROR code due to this beeing a non-leaving method
sl@0
   358
	TInt	errCode = 0;
sl@0
   359
	TRAP(errCode, iDevice->UseGcL(iIndex));
sl@0
   360
	iDevice->WriteStream() << ESetWordJustification;
sl@0
   361
	TRAP(errCode, iDevice->WriteStream().WriteInt32L(aExcessWidth));
sl@0
   362
	TRAP(errCode, iDevice->WriteStream().WriteInt32L(aNumGaps));
sl@0
   363
	}
sl@0
   364
sl@0
   365
EXPORT_C void CMetafileGc::SetCharJustification(TInt aExcessWidth,TInt aNumChars)
sl@0
   366
	{
sl@0
   367
	// TRAP and ignore the ERROR code due to this beeing a non-leaving method
sl@0
   368
	TInt	errCode = 0;
sl@0
   369
	TRAP(errCode, iDevice->UseGcL(iIndex));
sl@0
   370
	iDevice->WriteStream() << ESetCharJustification;
sl@0
   371
	TRAP(errCode, iDevice->WriteStream().WriteInt32L(aExcessWidth));
sl@0
   372
	TRAP(errCode, iDevice->WriteStream().WriteInt32L(aNumChars));
sl@0
   373
	}
sl@0
   374
sl@0
   375
EXPORT_C void CMetafileGc::SetPenColor(const TRgb& aColor)
sl@0
   376
	{
sl@0
   377
	// TRAP and ignore the ERROR code due to this beeing a non-leaving method
sl@0
   378
	TRAP_IGNORE(iDevice->UseGcL(iIndex));
sl@0
   379
	iDevice->WriteStream() << ESetPenColor;
sl@0
   380
	iDevice->WriteStream() << aColor;
sl@0
   381
	}
sl@0
   382
sl@0
   383
EXPORT_C void CMetafileGc::SetPenStyle(TPenStyle aPenStyle)
sl@0
   384
	{
sl@0
   385
	// TRAP and ignore the ERROR code due to this beeing a non-leaving method
sl@0
   386
	TInt	errCode = 0;
sl@0
   387
	TRAP(errCode, iDevice->UseGcL(iIndex));
sl@0
   388
	iDevice->WriteStream() << ESetPenStyle;
sl@0
   389
	TRAP(errCode, iDevice->WriteStream().WriteUint8L((TUint8) aPenStyle));
sl@0
   390
	}
sl@0
   391
sl@0
   392
EXPORT_C void CMetafileGc::SetPenSize(const TSize& aSize)
sl@0
   393
	{
sl@0
   394
	// TRAP and ignore the ERROR code due to this beeing a non-leaving method
sl@0
   395
	TRAP_IGNORE(iDevice->UseGcL(iIndex));
sl@0
   396
	iDevice->WriteStream() << ESetPenSize;
sl@0
   397
	iDevice->WriteStream() << aSize;
sl@0
   398
	}
sl@0
   399
sl@0
   400
EXPORT_C void CMetafileGc::SetBrushColor(const TRgb& aColor)
sl@0
   401
	{
sl@0
   402
	// TRAP and ignore the ERROR code due to this beeing a non-leaving method
sl@0
   403
	TRAP_IGNORE( iDevice->UseGcL(iIndex));
sl@0
   404
	iDevice->WriteStream() << ESetBrushColor;
sl@0
   405
	iDevice->WriteStream() << aColor;
sl@0
   406
	}
sl@0
   407
sl@0
   408
EXPORT_C void CMetafileGc::SetBrushStyle(TBrushStyle aBrushStyle)
sl@0
   409
	{
sl@0
   410
	// TRAP and ignore the ERROR code due to this beeing a non-leaving method
sl@0
   411
	TInt	errCode = 0;
sl@0
   412
	TRAP(errCode, iDevice->UseGcL(iIndex));
sl@0
   413
	iDevice->WriteStream() << ESetBrushStyle;
sl@0
   414
	TRAP(errCode, iDevice->WriteStream().WriteUint8L((TUint8) aBrushStyle));
sl@0
   415
	}
sl@0
   416
sl@0
   417
EXPORT_C void CMetafileGc::SetBrushOrigin(const TPoint& aOrigin)
sl@0
   418
	{
sl@0
   419
	// TRAP and ignore the ERROR code due to this beeing a non-leaving method
sl@0
   420
	TRAP_IGNORE(iDevice->UseGcL(iIndex));
sl@0
   421
	iDevice->WriteStream() << ESetBrushOrigin;
sl@0
   422
	iDevice->WriteStream() << aOrigin;
sl@0
   423
	}
sl@0
   424
sl@0
   425
EXPORT_C void CMetafileGc::UseBrushPattern(const CFbsBitmap* aBitmap)
sl@0
   426
	{
sl@0
   427
	// TRAP and ignore the ERROR code due to this beeing a non-leaving method
sl@0
   428
	TInt	errCode = 0;
sl@0
   429
	TRAP(errCode, iDevice->UseGcL(iIndex));
sl@0
   430
	iDevice->WriteStream() << EUseBrushPattern;
sl@0
   431
	TRAP(errCode, aBitmap->ExternalizeL(iDevice->WriteStream()));
sl@0
   432
	}
sl@0
   433
sl@0
   434
EXPORT_C void CMetafileGc::DiscardBrushPattern()
sl@0
   435
	{
sl@0
   436
	// TRAP and ignore the ERROR code due to this beeing a non-leaving method
sl@0
   437
	TRAP_IGNORE(iDevice->UseGcL(iIndex));
sl@0
   438
	iDevice->WriteStream() << EDiscardBrushPattern;
sl@0
   439
	}
sl@0
   440
sl@0
   441
EXPORT_C void CMetafileGc::MoveTo(const TPoint& aPoint)
sl@0
   442
	{
sl@0
   443
	// TRAP and ignore the ERROR code due to this beeing a non-leaving method
sl@0
   444
	TRAP_IGNORE(iDevice->UseGcL(iIndex));
sl@0
   445
	iDevice->WriteStream() << EMoveTo;
sl@0
   446
	iDevice->WriteStream() << aPoint;
sl@0
   447
	}
sl@0
   448
sl@0
   449
EXPORT_C void CMetafileGc::MoveBy(const TPoint& aVector)
sl@0
   450
	{
sl@0
   451
	// TRAP and ignore the ERROR code due to this beeing a non-leaving method
sl@0
   452
	TRAP_IGNORE(iDevice->UseGcL(iIndex));
sl@0
   453
	iDevice->WriteStream() << EMoveBy;
sl@0
   454
	iDevice->WriteStream() << aVector;
sl@0
   455
	}
sl@0
   456
sl@0
   457
EXPORT_C void CMetafileGc::Plot(const TPoint& aPoint)
sl@0
   458
	{
sl@0
   459
	// TRAP and ignore the ERROR code due to this beeing a non-leaving method
sl@0
   460
	TRAP_IGNORE(iDevice->UseGcL(iIndex));
sl@0
   461
	iDevice->WriteStream() << EPlot;
sl@0
   462
	iDevice->WriteStream() << aPoint;
sl@0
   463
	}
sl@0
   464
sl@0
   465
EXPORT_C void CMetafileGc::DrawArc(const TRect& aRect,const TPoint& aStart,const TPoint& aEnd)
sl@0
   466
	{
sl@0
   467
	// TRAP and ignore the ERROR code due to this beeing a non-leaving method
sl@0
   468
	TRAP_IGNORE(iDevice->UseGcL(iIndex));
sl@0
   469
	iDevice->WriteStream() << EDrawArc;
sl@0
   470
	iDevice->WriteStream() << aRect;
sl@0
   471
	iDevice->WriteStream() << aStart;
sl@0
   472
	iDevice->WriteStream() << aEnd;
sl@0
   473
	}
sl@0
   474
sl@0
   475
EXPORT_C void CMetafileGc::DrawLine(const TPoint& aPoint1,const TPoint& aPoint2)
sl@0
   476
	{
sl@0
   477
	// TRAP and ignore the ERROR code due to this beeing a non-leaving method
sl@0
   478
	TRAP_IGNORE(iDevice->UseGcL(iIndex));
sl@0
   479
	iDevice->WriteStream() << EDrawLine;
sl@0
   480
	iDevice->WriteStream() << aPoint1;
sl@0
   481
	iDevice->WriteStream() << aPoint2;
sl@0
   482
	}
sl@0
   483
sl@0
   484
EXPORT_C void CMetafileGc::DrawLineTo(const TPoint& aPoint)
sl@0
   485
	{
sl@0
   486
	// TRAP and ignore the ERROR code due to this beeing a non-leaving method
sl@0
   487
	TRAP_IGNORE(iDevice->UseGcL(iIndex));
sl@0
   488
	iDevice->WriteStream() << EDrawLineTo;
sl@0
   489
	iDevice->WriteStream() << aPoint;
sl@0
   490
	}
sl@0
   491
sl@0
   492
EXPORT_C void CMetafileGc::DrawLineBy(const TPoint& aVector)
sl@0
   493
	{
sl@0
   494
	// TRAP and ignore the ERROR code due to this beeing a non-leaving method
sl@0
   495
	TRAP_IGNORE(iDevice->UseGcL(iIndex));
sl@0
   496
	iDevice->WriteStream() << EDrawLineBy;
sl@0
   497
	iDevice->WriteStream() << aVector;
sl@0
   498
	}
sl@0
   499
sl@0
   500
EXPORT_C void CMetafileGc::DrawPolyLine(const CArrayFix<TPoint>* aPointList)
sl@0
   501
	{
sl@0
   502
	// TRAP and ignore the ERROR code due to this beeing a non-leaving method
sl@0
   503
	TInt	errCode = 0;
sl@0
   504
	TRAP(errCode, iDevice->UseGcL(iIndex));
sl@0
   505
	iDevice->WriteStream() << EDrawPolyLine1;
sl@0
   506
	
sl@0
   507
	TInt numpoints=aPointList->Count();
sl@0
   508
	TRAP(errCode, iDevice->WriteStream().WriteInt32L(numpoints));
sl@0
   509
	for (TInt i=0; i<numpoints; i++)
sl@0
   510
		iDevice->WriteStream() << (*aPointList)[i];
sl@0
   511
	}
sl@0
   512
sl@0
   513
EXPORT_C void CMetafileGc::DrawPolyLine(const TPoint* aPointList,TInt aNumPoints)
sl@0
   514
	{
sl@0
   515
	// TRAP and ignore the ERROR code due to this beeing a non-leaving method
sl@0
   516
	TInt	errCode = 0;
sl@0
   517
	TRAP(errCode, iDevice->UseGcL(iIndex));
sl@0
   518
	iDevice->WriteStream() << EDrawPolyLine2;
sl@0
   519
	TRAP(errCode, iDevice->WriteStream().WriteInt32L(aNumPoints));
sl@0
   520
	TPoint *p=(TPoint*) aPointList,*pEnd=p+aNumPoints;
sl@0
   521
	for (; p<pEnd; p++)
sl@0
   522
		iDevice->WriteStream() << *p;
sl@0
   523
	}
sl@0
   524
sl@0
   525
EXPORT_C void CMetafileGc::DrawPie(const TRect& aRect,const TPoint& aStart,const TPoint& aEnd)
sl@0
   526
	{
sl@0
   527
	// TRAP and ignore the ERROR code due to this beeing a non-leaving method
sl@0
   528
	TRAP_IGNORE(iDevice->UseGcL(iIndex));
sl@0
   529
	iDevice->WriteStream() << EDrawPie;
sl@0
   530
	iDevice->WriteStream() << aRect;
sl@0
   531
	iDevice->WriteStream() << aStart;
sl@0
   532
	iDevice->WriteStream() << aEnd;
sl@0
   533
	}
sl@0
   534
sl@0
   535
EXPORT_C void CMetafileGc::DrawEllipse(const TRect& aRect)
sl@0
   536
	{
sl@0
   537
	// TRAP and ignore the ERROR code due to this beeing a non-leaving method
sl@0
   538
	TRAP_IGNORE(iDevice->UseGcL(iIndex));
sl@0
   539
	iDevice->WriteStream() << EDrawEllipse;
sl@0
   540
	iDevice->WriteStream() << aRect;
sl@0
   541
	}
sl@0
   542
sl@0
   543
EXPORT_C void CMetafileGc::DrawRect(const TRect& aRect)
sl@0
   544
	{
sl@0
   545
	// TRAP and ignore the ERROR code due to this beeing a non-leaving method
sl@0
   546
	TRAP_IGNORE(iDevice->UseGcL(iIndex));
sl@0
   547
	iDevice->WriteStream() << EDrawRect;
sl@0
   548
	iDevice->WriteStream() << aRect;
sl@0
   549
	}
sl@0
   550
sl@0
   551
EXPORT_C void CMetafileGc::DrawRoundRect(const TRect& aRect,const TSize& aCornerSize)
sl@0
   552
	{
sl@0
   553
	// TRAP and ignore the ERROR code due to this beeing a non-leaving method
sl@0
   554
	TRAP_IGNORE(iDevice->UseGcL(iIndex));
sl@0
   555
	iDevice->WriteStream() << EDrawRoundRect;
sl@0
   556
	iDevice->WriteStream() << aRect;
sl@0
   557
	iDevice->WriteStream() << aCornerSize;
sl@0
   558
	}
sl@0
   559
sl@0
   560
EXPORT_C TInt CMetafileGc::DrawPolygon(const CArrayFix<TPoint>* aPointList,TFillRule aFillRule)
sl@0
   561
	{
sl@0
   562
	// TRAP and ignore the ERROR code due to this beeing a non-leaving method
sl@0
   563
	TInt	errCode = 0;
sl@0
   564
	TRAP(errCode, iDevice->UseGcL(iIndex));
sl@0
   565
	iDevice->WriteStream() << EDrawPolygon1;
sl@0
   566
	TInt numpoints=aPointList->Count();
sl@0
   567
	TRAP(errCode, iDevice->WriteStream().WriteInt32L(numpoints));
sl@0
   568
	for (TInt i=0; i<numpoints; i++)
sl@0
   569
		iDevice->WriteStream() << (*aPointList)[i];
sl@0
   570
	TRAP(errCode, iDevice->WriteStream().WriteUint8L((TUint8) aFillRule));
sl@0
   571
	return KErrNone;
sl@0
   572
	}
sl@0
   573
sl@0
   574
EXPORT_C TInt CMetafileGc::DrawPolygon(const TPoint* aPointList,TInt aNumPoints,TFillRule aFillRule)
sl@0
   575
	{
sl@0
   576
	// TRAP and ignore the ERROR code due to this beeing a non-leaving method
sl@0
   577
	TInt	errCode = 0;
sl@0
   578
	TRAP(errCode, iDevice->UseGcL(iIndex));
sl@0
   579
	iDevice->WriteStream() << EDrawPolygon2;
sl@0
   580
	TRAP(errCode, iDevice->WriteStream().WriteInt32L(aNumPoints));
sl@0
   581
	TPoint *p=(TPoint*) aPointList,*pEnd=p+aNumPoints;
sl@0
   582
	for (; p<pEnd; p++)
sl@0
   583
		iDevice->WriteStream() << *p;
sl@0
   584
	TRAP(errCode, iDevice->WriteStream().WriteUint8L((TUint8) aFillRule));
sl@0
   585
	return KErrNone;
sl@0
   586
	}
sl@0
   587
sl@0
   588
EXPORT_C void CMetafileGc::DrawBitmap(const TPoint& aTopLeft,const CFbsBitmap* aSource)
sl@0
   589
	{
sl@0
   590
	// TRAP and ignore the ERROR code due to this beeing a non-leaving method
sl@0
   591
	TInt	errCode = 0;
sl@0
   592
	TRAP(errCode, iDevice->UseGcL(iIndex));
sl@0
   593
	iDevice->WriteStream() << EDrawBitmap1;
sl@0
   594
	iDevice->WriteStream() << aTopLeft;
sl@0
   595
	TRAP(errCode, ExternalizeBitmapL(aSource));
sl@0
   596
	}
sl@0
   597
sl@0
   598
EXPORT_C void CMetafileGc::DrawBitmap(const TRect& aDestRect,const CFbsBitmap* aSource)
sl@0
   599
	{
sl@0
   600
	// TRAP and ignore the ERROR code due to this beeing a non-leaving method
sl@0
   601
	TInt	errCode = 0;
sl@0
   602
	TRAP(errCode, iDevice->UseGcL(iIndex));
sl@0
   603
	iDevice->WriteStream() << EDrawBitmap2;
sl@0
   604
	iDevice->WriteStream() << aDestRect;
sl@0
   605
	TRAP(errCode, ExternalizeBitmapL(aSource));
sl@0
   606
	}
sl@0
   607
sl@0
   608
EXPORT_C void CMetafileGc::DrawBitmap(const TRect& aDestRect,const CFbsBitmap* aSource,const TRect& aSourceRect)
sl@0
   609
	{
sl@0
   610
	// TRAP and ignore the ERROR code due to this beeing a non-leaving method
sl@0
   611
	TInt	errCode = 0;
sl@0
   612
	TRAP(errCode, iDevice->UseGcL(iIndex));
sl@0
   613
	iDevice->WriteStream() << EDrawBitmap3;
sl@0
   614
	iDevice->WriteStream() << aDestRect;
sl@0
   615
	TRAP(errCode, ExternalizeBitmapL(aSource));
sl@0
   616
	iDevice->WriteStream() << aSourceRect;
sl@0
   617
	}
sl@0
   618
sl@0
   619
EXPORT_C void CMetafileGc::DrawBitmapMasked(const TRect& /*aDestRect*/,const CFbsBitmap* /*aBitmap*/,const TRect& /*aSourceRect*/,const CFbsBitmap* /*aMaskBitmap*/,TBool /*aInvertMask*/)
sl@0
   620
	{}
sl@0
   621
sl@0
   622
EXPORT_C void CMetafileGc::DrawBitmapMasked(const TRect& /*aDestRect*/,const CWsBitmap* /*aBitmap*/,const TRect& /*aSourceRect*/,const CWsBitmap* /*aMaskBitmap*/,TBool /*aInvertMask*/)
sl@0
   623
	{}
sl@0
   624
		
sl@0
   625
EXPORT_C void CMetafileGc::MapColors(const TRect& /*aRect*/,const TRgb* /*aColors*/,TInt /*aNumPairs*/,TBool /*aMapForwards*/)
sl@0
   626
	{}
sl@0
   627
sl@0
   628
EXPORT_C TInt CMetafileGc::SetClippingRegion(const TRegion &/*aRegion*/)
sl@0
   629
	{	
sl@0
   630
		return KErrNone;
sl@0
   631
	}
sl@0
   632
sl@0
   633
EXPORT_C void CMetafileGc::CancelClippingRegion()
sl@0
   634
	{}
sl@0
   635
sl@0
   636
EXPORT_C void CMetafileGc::DrawTextVertical(const TDesC& /*aText*/,const TPoint& /*aPos*/,TBool /*aUp*/)
sl@0
   637
	{}
sl@0
   638
	
sl@0
   639
EXPORT_C void CMetafileGc::DrawTextVertical(const TDesC& /*aText*/,const TRect& /*aBox*/,TInt /*aBaselineOffset*/,TBool /*aUp*/,TTextAlign /*aVert*/,TInt /*aMargin*/)
sl@0
   640
	{}
sl@0
   641
sl@0
   642
EXPORT_C TInt CMetafileGc::AlphaBlendBitmaps(const TPoint& /*aDestPt*/, const CFbsBitmap* /*aSrcBmp*/, const TRect& /*aSrcRect*/, const CFbsBitmap* /*aAlphaBmp*/, const TPoint& /*aAlphaPt*/) 
sl@0
   643
	{
sl@0
   644
		return KErrNone;
sl@0
   645
	}
sl@0
   646
	
sl@0
   647
EXPORT_C TInt CMetafileGc::AlphaBlendBitmaps(const TPoint& /*aDestPt*/, const CWsBitmap* /*aSrcBmp*/,  const TRect& /*aSrcRect*/, const CWsBitmap*  /*aAlphaBmp*/, const TPoint& /*aAlphaPt*/)
sl@0
   648
	{
sl@0
   649
		return KErrNone;
sl@0
   650
	}
sl@0
   651
sl@0
   652
sl@0
   653
EXPORT_C void CMetafileGc::DrawText(const TDesC& aString,const TPoint& aPosition)
sl@0
   654
	{
sl@0
   655
	// TRAP and ignore the ERROR code due to this beeing a non-leaving method
sl@0
   656
	TRAP_IGNORE(iDevice->UseGcL(iIndex));
sl@0
   657
	iDevice->WriteStream() << EDrawText1;
sl@0
   658
	iDevice->WriteStream() << aString;
sl@0
   659
	iDevice->WriteStream() << aPosition;
sl@0
   660
	}
sl@0
   661
sl@0
   662
EXPORT_C void CMetafileGc::DrawText(const TDesC& aString,const TRect& aBox,TInt aBaselineOffset,TTextAlign aHoriz,TInt aLeftMrg)
sl@0
   663
	{
sl@0
   664
	// TRAP and ignore the ERROR code due to this beeing a non-leaving method
sl@0
   665
	TInt	errCode = 0;
sl@0
   666
	TRAP(errCode, iDevice->UseGcL(iIndex));
sl@0
   667
	iDevice->WriteStream() << EDrawText2;
sl@0
   668
	iDevice->WriteStream() << aString;
sl@0
   669
	iDevice->WriteStream() << aBox;
sl@0
   670
	TRAP(errCode, iDevice->WriteStream().WriteInt32L(aBaselineOffset));
sl@0
   671
	TRAP(errCode, iDevice->WriteStream().WriteUint8L((TUint8) aHoriz));
sl@0
   672
	TRAP(errCode, iDevice->WriteStream().WriteInt32L(aLeftMrg));
sl@0
   673
	}
sl@0
   674
sl@0
   675
void CMetafileGc::ExternalizeBitmapL(const CFbsBitmap* aSource)
sl@0
   676
	{
sl@0
   677
	CFbsBitmap* bitmap=new(ELeave)	CFbsBitmap;
sl@0
   678
	CleanupStack::PushL(bitmap);
sl@0
   679
	User::LeaveIfError(bitmap->Create(aSource->SizeInPixels(),iDevice->DisplayMode()));
sl@0
   680
	CFbsBitmapDevice* bitmapdevice=CFbsBitmapDevice::NewL(bitmap);
sl@0
   681
	CleanupStack::PushL(bitmapdevice);
sl@0
   682
	CFbsBitGc* gc;
sl@0
   683
	User::LeaveIfError(bitmapdevice->CreateContext((CGraphicsContext*&) gc));
sl@0
   684
	CleanupStack::PushL(gc);
sl@0
   685
	gc->BitBlt(TPoint(0,0),aSource);
sl@0
   686
	bitmap->ExternalizeL(iDevice->WriteStream());
sl@0
   687
	CleanupStack::PopAndDestroy(3);
sl@0
   688
	}
sl@0
   689
sl@0
   690
EXPORT_C CMetafilePlayback::CMetafilePlayback(CGraphicsDevice* aDevice):
sl@0
   691
	iDevice(aDevice)	
sl@0
   692
	{
sl@0
   693
	__DECLARE_NAME(_S("CMetafilePlayback"));
sl@0
   694
	}
sl@0
   695
sl@0
   696
EXPORT_C CMetafilePlayback* CMetafilePlayback::NewL(CGraphicsDevice* aDevice)
sl@0
   697
	{
sl@0
   698
	CMetafilePlayback* playback=new(ELeave) CMetafilePlayback(aDevice);
sl@0
   699
	return playback;
sl@0
   700
	}
sl@0
   701
sl@0
   702
EXPORT_C CMetafilePlayback::~CMetafilePlayback()
sl@0
   703
	{
sl@0
   704
	}
sl@0
   705
sl@0
   706
sl@0
   707
EXPORT_C void CMetafilePlayback::DrawL(RReadStream& aReadStream)
sl@0
   708
	{
sl@0
   709
	CArrayPtrFlat<CGraphicsContext>* gclist=new(ELeave) CArrayPtrFlat<CGraphicsContext>(8);
sl@0
   710
	CleanupStack::PushL(gclist);
sl@0
   711
	CFontStack* fontstack = CFontStack::NewL(iDevice);
sl@0
   712
	CleanupStack::PushL(fontstack);
sl@0
   713
	CArrayFixFlat<TPoint>* pointlist=new(ELeave) CArrayFixFlat<TPoint>(8);
sl@0
   714
	CleanupStack::PushL(pointlist);
sl@0
   715
	CFbsBitmap* bitmap=new(ELeave) CFbsBitmap;
sl@0
   716
	CleanupStack::PushL(bitmap);
sl@0
   717
	TSize kpixelsizeintwips;
sl@0
   718
	aReadStream	>> kpixelsizeintwips;
sl@0
   719
	TGraphicsContextCommandCode code;
sl@0
   720
	TInt gcindex=0;
sl@0
   721
	do
sl@0
   722
		{
sl@0
   723
		code = (TGraphicsContextCommandCode) aReadStream.ReadUint8L();
sl@0
   724
		switch (code)
sl@0
   725
			{
sl@0
   726
			case EUseGc:
sl@0
   727
				{
sl@0
   728
				TInt gcindex=aReadStream.ReadInt32L();
sl@0
   729
				if (gcindex>=gclist->Count())
sl@0
   730
					{
sl@0
   731
					for (TInt i=gclist->Count(); i<=gcindex; i++)
sl@0
   732
						{
sl@0
   733
						CGraphicsContext* gc;
sl@0
   734
						User::LeaveIfError(iDevice->CreateContext(gc));
sl@0
   735
						CleanupStack::PushL(gc);
sl@0
   736
						gclist->AppendL(gc);
sl@0
   737
						}
sl@0
   738
					}
sl@0
   739
sl@0
   740
				break;
sl@0
   741
				}
sl@0
   742
			case EEndOfStream:
sl@0
   743
				{
sl@0
   744
				break;
sl@0
   745
				}
sl@0
   746
			case ESetOrigin:
sl@0
   747
				{
sl@0
   748
				TPoint pos;
sl@0
   749
				aReadStream >> pos;
sl@0
   750
				(*gclist)[gcindex]->SetOrigin(pos);
sl@0
   751
				break;
sl@0
   752
				}
sl@0
   753
			case ESetDrawMode:
sl@0
   754
				{
sl@0
   755
				CGraphicsContext::TDrawMode drawingmode;
sl@0
   756
				drawingmode = (CGraphicsContext::TDrawMode) aReadStream.ReadUint8L();
sl@0
   757
				(*gclist)[gcindex]->SetDrawMode(drawingmode);
sl@0
   758
				break;
sl@0
   759
				}
sl@0
   760
			case ESetClippingRect:
sl@0
   761
				{
sl@0
   762
				TRect rect;
sl@0
   763
				aReadStream >> rect;
sl@0
   764
				(*gclist)[gcindex]->SetClippingRect(rect);
sl@0
   765
				break;
sl@0
   766
				}
sl@0
   767
			case ECancelClippingRect:
sl@0
   768
				{
sl@0
   769
				(*gclist)[gcindex]->CancelClippingRect();
sl@0
   770
				break;
sl@0
   771
				}
sl@0
   772
			case EReset:
sl@0
   773
				{
sl@0
   774
				(*gclist)[gcindex]->CancelClippingRect();
sl@0
   775
				break;
sl@0
   776
				}
sl@0
   777
			case EUseFont:
sl@0
   778
				{
sl@0
   779
				TFontSpec spec;
sl@0
   780
				aReadStream >> spec;
sl@0
   781
				aReadStream.ReadInt32L();  // height in pixels
sl@0
   782
				aReadStream.ReadInt32L();  // baseline offset in pixels
sl@0
   783
				spec.iHeight=((spec.iHeight*iDevice->VerticalPixelsToTwips(1000))+(kpixelsizeintwips.iHeight/2))/kpixelsizeintwips.iHeight;
sl@0
   784
				CFont* font;
sl@0
   785
				User::LeaveIfError(iDevice->GetNearestFontToDesignHeightInTwips(font,spec));
sl@0
   786
				fontstack->AddFontL(font);
sl@0
   787
				(*gclist)[gcindex]->UseFont(font);
sl@0
   788
				break;
sl@0
   789
				}
sl@0
   790
			case EDiscardFont:
sl@0
   791
				{
sl@0
   792
				(*gclist)[gcindex]->DiscardFont();
sl@0
   793
				break;
sl@0
   794
				}
sl@0
   795
			case ESetUnderlineStyle:
sl@0
   796
				{
sl@0
   797
				TFontUnderline underlinestyle;
sl@0
   798
				underlinestyle = (TFontUnderline) aReadStream.ReadUint8L();
sl@0
   799
				(*gclist)[gcindex]->SetUnderlineStyle(underlinestyle);
sl@0
   800
				break;
sl@0
   801
				}
sl@0
   802
			case ESetStrikethroughStyle:
sl@0
   803
				{
sl@0
   804
				TFontStrikethrough strikethroughstyle;
sl@0
   805
				strikethroughstyle = (TFontStrikethrough) aReadStream.ReadUint8L();
sl@0
   806
				(*gclist)[gcindex]->SetStrikethroughStyle(strikethroughstyle);
sl@0
   807
				break;
sl@0
   808
				}
sl@0
   809
			case ESetWordJustification:
sl@0
   810
				{
sl@0
   811
				TInt excesswidth,numgaps;
sl@0
   812
				excesswidth=aReadStream.ReadInt32L();
sl@0
   813
				numgaps=aReadStream.ReadInt32L();
sl@0
   814
				(*gclist)[gcindex]->SetWordJustification(excesswidth,numgaps);
sl@0
   815
				break;
sl@0
   816
				}
sl@0
   817
			case ESetCharJustification:
sl@0
   818
				{
sl@0
   819
				TInt excesswidth,numgaps;
sl@0
   820
				excesswidth=aReadStream.ReadInt32L();
sl@0
   821
				numgaps=aReadStream.ReadInt32L();
sl@0
   822
				(*gclist)[gcindex]->SetCharJustification(excesswidth,numgaps);
sl@0
   823
				break;
sl@0
   824
				}
sl@0
   825
			case ESetPenColor:
sl@0
   826
				{
sl@0
   827
				TRgb color;
sl@0
   828
				aReadStream >> color;
sl@0
   829
				(*gclist)[gcindex]->SetPenColor(color);
sl@0
   830
				break;
sl@0
   831
				}
sl@0
   832
			case ESetPenStyle:
sl@0
   833
				{
sl@0
   834
				CGraphicsContext::TPenStyle penstyle;
sl@0
   835
				penstyle=(CGraphicsContext::TPenStyle) aReadStream.ReadUint8L();
sl@0
   836
				(*gclist)[gcindex]->SetPenStyle(penstyle);
sl@0
   837
				break;
sl@0
   838
				}
sl@0
   839
			case ESetPenSize:
sl@0
   840
				{
sl@0
   841
				TSize size;
sl@0
   842
				aReadStream >> size;
sl@0
   843
				(*gclist)[gcindex]->SetPenSize(size);
sl@0
   844
				break;
sl@0
   845
				}
sl@0
   846
			case ESetBrushColor:
sl@0
   847
				{
sl@0
   848
				TRgb color;
sl@0
   849
				aReadStream >> color;
sl@0
   850
				(*gclist)[gcindex]->SetBrushColor(color);
sl@0
   851
				break;
sl@0
   852
				}
sl@0
   853
			case ESetBrushStyle:
sl@0
   854
				{
sl@0
   855
				CGraphicsContext::TBrushStyle brushstyle;
sl@0
   856
				brushstyle = (CGraphicsContext::TBrushStyle) aReadStream.ReadUint8L();
sl@0
   857
				(*gclist)[gcindex]->SetBrushStyle(brushstyle);
sl@0
   858
				break;
sl@0
   859
				}
sl@0
   860
			case ESetBrushOrigin:
sl@0
   861
				{
sl@0
   862
				TPoint origin;
sl@0
   863
				aReadStream >> origin;
sl@0
   864
				(*gclist)[gcindex]->SetBrushOrigin(origin);
sl@0
   865
				break;
sl@0
   866
				}
sl@0
   867
			case EUseBrushPattern:
sl@0
   868
				{
sl@0
   869
				bitmap->InternalizeL(aReadStream);
sl@0
   870
				(*gclist)[gcindex]->UseBrushPattern(bitmap);
sl@0
   871
				bitmap->Reset();
sl@0
   872
				break;
sl@0
   873
				}
sl@0
   874
			case EDiscardBrushPattern:
sl@0
   875
				{
sl@0
   876
				(*gclist)[gcindex]->DiscardBrushPattern();
sl@0
   877
				break;
sl@0
   878
				}
sl@0
   879
			case EMoveTo:
sl@0
   880
				{
sl@0
   881
				TPoint point;
sl@0
   882
				aReadStream >> point;
sl@0
   883
				(*gclist)[gcindex]->MoveTo(point);
sl@0
   884
				break;
sl@0
   885
				}
sl@0
   886
			case EMoveBy:
sl@0
   887
				{
sl@0
   888
				TPoint vector;
sl@0
   889
				aReadStream >> vector;
sl@0
   890
				(*gclist)[gcindex]->MoveBy(vector);
sl@0
   891
				break;
sl@0
   892
				}
sl@0
   893
			case EPlot:
sl@0
   894
				{
sl@0
   895
				TPoint point;
sl@0
   896
				aReadStream >> point;
sl@0
   897
				(*gclist)[gcindex]->Plot(point);
sl@0
   898
				break;
sl@0
   899
				}
sl@0
   900
			case EDrawArc:
sl@0
   901
				{
sl@0
   902
				TRect rect;
sl@0
   903
				aReadStream >> rect;
sl@0
   904
				TPoint start,end;
sl@0
   905
				aReadStream >> start;
sl@0
   906
				aReadStream >> end;
sl@0
   907
				(*gclist)[gcindex]->DrawArc(rect,start,end);
sl@0
   908
				break;
sl@0
   909
				}
sl@0
   910
			case EDrawLine:
sl@0
   911
				{
sl@0
   912
				TPoint point1,point2;
sl@0
   913
				aReadStream >> point1;
sl@0
   914
				aReadStream >> point2;
sl@0
   915
				(*gclist)[gcindex]->DrawLine(point1,point2);
sl@0
   916
				break;
sl@0
   917
				}
sl@0
   918
			case EDrawLineTo:
sl@0
   919
				{
sl@0
   920
				TPoint point;
sl@0
   921
				aReadStream >> point;
sl@0
   922
				(*gclist)[gcindex]->DrawLineTo(point);
sl@0
   923
				break;
sl@0
   924
				}
sl@0
   925
			case EDrawLineBy:
sl@0
   926
				{
sl@0
   927
				TPoint vector;
sl@0
   928
				aReadStream >> vector;
sl@0
   929
				(*gclist)[gcindex]->DrawLineBy(vector);
sl@0
   930
				break;
sl@0
   931
				}
sl@0
   932
			case EDrawPolyLine1: 
sl@0
   933
				{
sl@0
   934
				}
sl@0
   935
			case EDrawPolyLine2: 
sl@0
   936
				{
sl@0
   937
				TInt numpoints;
sl@0
   938
				numpoints=aReadStream.ReadInt32L();
sl@0
   939
				for (TInt i=0; i<numpoints; i++)
sl@0
   940
					{
sl@0
   941
					TPoint point;
sl@0
   942
					aReadStream >> point;
sl@0
   943
					pointlist->AppendL(point);
sl@0
   944
					}
sl@0
   945
				(*gclist)[gcindex]->DrawPolyLine(pointlist);
sl@0
   946
				pointlist->Reset();
sl@0
   947
				break;
sl@0
   948
				}
sl@0
   949
			case EDrawPie:
sl@0
   950
				{
sl@0
   951
				TRect rect;
sl@0
   952
				aReadStream >> rect;
sl@0
   953
				TPoint start,end;
sl@0
   954
				aReadStream >> start;
sl@0
   955
				aReadStream >> end;
sl@0
   956
				(*gclist)[gcindex]->DrawPie(rect,start,end);
sl@0
   957
				break;
sl@0
   958
				}
sl@0
   959
			case EDrawEllipse:
sl@0
   960
				{
sl@0
   961
				TRect rect;
sl@0
   962
				aReadStream >> rect;
sl@0
   963
				(*gclist)[gcindex]->DrawEllipse(rect);
sl@0
   964
				break;
sl@0
   965
				}
sl@0
   966
			case EDrawRect:
sl@0
   967
				{
sl@0
   968
				TRect rect;
sl@0
   969
				aReadStream >> rect;
sl@0
   970
				(*gclist)[gcindex]->DrawRect(rect);
sl@0
   971
				break;
sl@0
   972
				}
sl@0
   973
			case EDrawRoundRect:
sl@0
   974
				{
sl@0
   975
				TRect rect;
sl@0
   976
				aReadStream >> rect;
sl@0
   977
				TSize cornersize;
sl@0
   978
				aReadStream >> cornersize;
sl@0
   979
				(*gclist)[gcindex]->DrawRoundRect(rect,cornersize);
sl@0
   980
				break;
sl@0
   981
				}
sl@0
   982
			case EDrawPolygon1:  
sl@0
   983
				{
sl@0
   984
				}
sl@0
   985
			case EDrawPolygon2:  
sl@0
   986
				{
sl@0
   987
				TInt numpoints;
sl@0
   988
				numpoints=aReadStream.ReadInt32L();
sl@0
   989
				for (TInt i=0; i<numpoints; i++)
sl@0
   990
					{
sl@0
   991
					TPoint point;
sl@0
   992
					aReadStream >> point;
sl@0
   993
					pointlist->AppendL(point);
sl@0
   994
					}
sl@0
   995
				CGraphicsContext::TFillRule fillrule=(CGraphicsContext::TFillRule) aReadStream.ReadUint8L();
sl@0
   996
				(*gclist)[gcindex]->DrawPolygon(pointlist,fillrule);
sl@0
   997
				pointlist->Reset();
sl@0
   998
				break;
sl@0
   999
				}
sl@0
  1000
			case EDrawBitmap1:   
sl@0
  1001
				{
sl@0
  1002
				TPoint topleft;
sl@0
  1003
				aReadStream >> topleft;
sl@0
  1004
				bitmap->InternalizeL(aReadStream);
sl@0
  1005
				(*gclist)[gcindex]->DrawBitmap(topleft,bitmap);
sl@0
  1006
				bitmap->Reset();
sl@0
  1007
				break;
sl@0
  1008
				}
sl@0
  1009
			case EDrawBitmap2:   
sl@0
  1010
				{
sl@0
  1011
				TRect destrect;
sl@0
  1012
				aReadStream >> destrect;
sl@0
  1013
				bitmap->InternalizeL(aReadStream);
sl@0
  1014
				(*gclist)[gcindex]->DrawBitmap(destrect,bitmap);
sl@0
  1015
				bitmap->Reset();
sl@0
  1016
				break;
sl@0
  1017
				}
sl@0
  1018
			case EDrawBitmap3:   
sl@0
  1019
				{
sl@0
  1020
				TRect destrect;
sl@0
  1021
				aReadStream >> destrect;
sl@0
  1022
				bitmap->InternalizeL(aReadStream);
sl@0
  1023
				TRect sourcerect;
sl@0
  1024
				aReadStream >> sourcerect;
sl@0
  1025
				(*gclist)[gcindex]->DrawBitmap(destrect,bitmap,sourcerect);
sl@0
  1026
				bitmap->Reset();
sl@0
  1027
				break;
sl@0
  1028
				}
sl@0
  1029
			case EDrawText1:	    
sl@0
  1030
				{
sl@0
  1031
				HBufC* string=HBufC::NewLC(aReadStream,KMaxTInt);
sl@0
  1032
				TPoint position;
sl@0
  1033
				aReadStream >> position;
sl@0
  1034
				(*gclist)[gcindex]->DrawText(*string,position);
sl@0
  1035
				CleanupStack::PopAndDestroy();
sl@0
  1036
				break;
sl@0
  1037
				}
sl@0
  1038
			case EDrawText2:	    
sl@0
  1039
				{
sl@0
  1040
				HBufC* string=HBufC::NewLC(aReadStream,KMaxTInt);
sl@0
  1041
				TRect box;
sl@0
  1042
				aReadStream >> box;
sl@0
  1043
				TInt baselineoffset=aReadStream.ReadInt32L();
sl@0
  1044
				CGraphicsContext::TTextAlign horiz=(CGraphicsContext::TTextAlign) aReadStream.ReadUint8L();
sl@0
  1045
				TInt leftmrg=aReadStream.ReadInt32L();
sl@0
  1046
				(*gclist)[gcindex]->DrawText(*string,box,baselineoffset,horiz,leftmrg);
sl@0
  1047
				CleanupStack::PopAndDestroy();
sl@0
  1048
				break;
sl@0
  1049
				}
sl@0
  1050
			}
sl@0
  1051
		}
sl@0
  1052
	while (code!=EEndOfStream);
sl@0
  1053
	CleanupStack::PopAndDestroy(gclist->Count()+4);
sl@0
  1054
	}