|
1 // Copyright (c) 2008-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 /** |
|
17 @file |
|
18 @test |
|
19 @internalComponent - Internal Symbian test code |
|
20 */ |
|
21 |
|
22 #include "spriteanimdll.h" |
|
23 |
|
24 EXPORT_C CAnimDll *CreateCAnimDllL() |
|
25 { |
|
26 return(new(ELeave) CTAnimDll()); |
|
27 } |
|
28 |
|
29 CAnim* CTAnimDll::CreateInstanceL(TInt aType) |
|
30 { |
|
31 CAnim *anim=NULL; |
|
32 switch(aType) |
|
33 { |
|
34 case ESpriteAnimType: |
|
35 anim=new(ELeave) CTSpriteAnim(); |
|
36 break; |
|
37 } |
|
38 return anim; |
|
39 } |
|
40 |
|
41 // CTSpriteAnim test sprite access // |
|
42 |
|
43 void CTSpriteAnim::ConstructL(TAny* /*aParam*/) |
|
44 { |
|
45 iSpriteFunctions->SizeChangedL(); |
|
46 iSpriteFunctions->Activate(ETrue); |
|
47 } |
|
48 |
|
49 |
|
50 void CTSpriteAnim::Animate(TDateTime*) |
|
51 { |
|
52 } |
|
53 |
|
54 void CTSpriteAnim::Command(TInt aOpcode,TAny* /*aParam*/) |
|
55 { |
|
56 switch (aOpcode) |
|
57 { |
|
58 case EADllDraw1: |
|
59 case EADllDraw2: |
|
60 case EADllDraw3: |
|
61 case EADllDrawBlank: |
|
62 TRAPD(err,DrawL(aOpcode)); |
|
63 if (err) |
|
64 { |
|
65 RDebug::Print(_L("CTSpriteAnim::Command - DrawL leave error: %d"), err); |
|
66 } |
|
67 break; |
|
68 default:; |
|
69 } |
|
70 } |
|
71 |
|
72 TInt CTSpriteAnim::CommandReplyL(TInt /*aOpcode*/,TAny* /*aParam*/) |
|
73 { |
|
74 return(KErrNone); |
|
75 } |
|
76 |
|
77 |
|
78 TBool CTSpriteAnim::OfferRawEvent(const TRawEvent& /*aRawEvent*/) |
|
79 { |
|
80 return EFalse; |
|
81 } |
|
82 |
|
83 void CTSpriteAnim::DrawL(TInt aOpcode) |
|
84 { |
|
85 CFbsBitmap *bitmap=iSpriteFunctions->GetSpriteMember(0)->iBitmap; |
|
86 CFbsBitmapDevice *device=CFbsBitmapDevice::NewL(bitmap); |
|
87 CleanupStack::PushL(device); |
|
88 CFbsBitGc *gc; |
|
89 User::LeaveIfError(device->CreateContext(gc)); |
|
90 CleanupStack::PushL(gc); |
|
91 |
|
92 gc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
93 gc->SetPenSize(TSize()); |
|
94 TSize bitmapSize=bitmap->SizeInPixels(); |
|
95 TSize size= bitmapSize; |
|
96 size.SetSize(size.iWidth/2,size.iHeight/2); |
|
97 TPoint point=size.AsPoint(); |
|
98 |
|
99 // according to the opcode used, a quarter of the sprite bitmap is drawn to a different colour |
|
100 switch(aOpcode) |
|
101 { |
|
102 case EADllDraw1: |
|
103 { |
|
104 gc->SetBrushColor(TRgb(255,0,0)); |
|
105 gc->DrawRect(TRect(TPoint(),size)); |
|
106 break; |
|
107 } |
|
108 case EADllDraw2: |
|
109 { |
|
110 gc->SetBrushColor(TRgb(0,255,0)); |
|
111 gc->DrawRect(TRect(TPoint(point.iX,0),size)); |
|
112 break; |
|
113 } |
|
114 case EADllDraw3: |
|
115 { |
|
116 gc->SetBrushColor(TRgb(0,0,255)); |
|
117 gc->DrawRect(TRect(TPoint(0,point.iY),size)); |
|
118 break; |
|
119 } |
|
120 case EADllDrawBlank: |
|
121 {//the whole sprite bitmap is set to blank |
|
122 gc->SetBrushColor(TRgb(255,255,255)); |
|
123 gc->DrawRect(TRect(TPoint(),bitmapSize)); |
|
124 break; |
|
125 } |
|
126 default:; |
|
127 } |
|
128 iSpriteFunctions->UpdateMember(0,TRect(bitmap->SizeInPixels()),ETrue); |
|
129 CleanupStack::PopAndDestroy(2); //gc and device |
|
130 } |