|
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 "tspriteanimdll.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 User::LeaveIfNull(iSpriteFunctions); |
|
46 iSpriteFunctions->SizeChangedL(); |
|
47 iSpriteFunctions->Activate(ETrue); |
|
48 } |
|
49 |
|
50 |
|
51 void CTSpriteAnim::Animate(TDateTime*) |
|
52 { |
|
53 } |
|
54 |
|
55 void CTSpriteAnim::Command(TInt aOpcode, TAny* /*aArgs*/) |
|
56 { |
|
57 switch (aOpcode) |
|
58 { |
|
59 case EADllDraw1: |
|
60 case EADllDraw2: |
|
61 case EADllDraw3: |
|
62 case EADllDrawBlank: |
|
63 TRAPD(err,DrawL(aOpcode)); |
|
64 if (err) |
|
65 { |
|
66 RDebug::Print(_L("CTSpriteAnim::Command - DrawL error: %d"), err); |
|
67 } |
|
68 break; |
|
69 default:; |
|
70 } |
|
71 } |
|
72 |
|
73 TInt CTSpriteAnim::CommandReplyL(TInt /*aOpcode*/,TAny* /*aParam*/) |
|
74 { |
|
75 return(KErrNone); |
|
76 } |
|
77 |
|
78 |
|
79 TBool CTSpriteAnim::OfferRawEvent(const TRawEvent& /*aRawEvent*/) |
|
80 { |
|
81 return EFalse; |
|
82 } |
|
83 |
|
84 void CTSpriteAnim::DrawL(TInt aOpcode) |
|
85 { |
|
86 TSpriteMember *spriteMember = iSpriteFunctions->GetSpriteMember(0); |
|
87 User::LeaveIfNull(spriteMember); |
|
88 CFbsBitmap *bitmap=spriteMember->iBitmap; |
|
89 CFbsBitmapDevice *device=CFbsBitmapDevice::NewL(bitmap); |
|
90 CleanupStack::PushL(device); |
|
91 CFbsBitGc *gc; |
|
92 User::LeaveIfError(device->CreateContext(gc)); |
|
93 CleanupStack::PushL(gc); |
|
94 |
|
95 gc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
96 gc->SetPenSize(TSize()); |
|
97 TSize bitmapSize=bitmap->SizeInPixels(); |
|
98 TSize size= bitmapSize; |
|
99 size.SetSize(size.iWidth/2,size.iHeight/2); |
|
100 TPoint point=size.AsPoint(); |
|
101 |
|
102 // according to the opcode used, a quarter of the sprite bitmap is drawn to a different colour |
|
103 switch(aOpcode) |
|
104 { |
|
105 case EADllDraw1: |
|
106 { |
|
107 gc->SetBrushColor(TRgb(255,0,0)); |
|
108 gc->DrawRect(TRect(TPoint(),size)); |
|
109 break; |
|
110 } |
|
111 case EADllDraw2: |
|
112 { |
|
113 gc->SetBrushColor(TRgb(0,255,0)); |
|
114 gc->DrawRect(TRect(TPoint(point.iX,0),size)); |
|
115 break; |
|
116 } |
|
117 case EADllDraw3: |
|
118 { |
|
119 gc->SetBrushColor(TRgb(0,0,255)); |
|
120 gc->DrawRect(TRect(TPoint(0,point.iY),size)); |
|
121 break; |
|
122 } |
|
123 case EADllDrawBlank: |
|
124 {//the whole sprite bitmap is set to blank |
|
125 gc->SetBrushColor(TRgb(255,255,255)); |
|
126 gc->DrawRect(TRect(TPoint(),bitmapSize)); |
|
127 break; |
|
128 } |
|
129 default:; |
|
130 } |
|
131 iSpriteFunctions->UpdateMember(0,TRect(bitmap->SizeInPixels()),ETrue); |
|
132 CleanupStack::PopAndDestroy(2); //gc and device |
|
133 } |