1 /* |
|
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "txtfrmat.h" |
|
19 #include "bitdev.h" |
|
20 #include "T_AnimProc.h" |
|
21 #include "T_TSpriteAnim.h" |
|
22 #include "T_TestAnimDll.h" |
|
23 #include "w32std.h" |
|
24 #include "T_AnimDef.h" |
|
25 |
|
26 CTSpriteAnim::CTSpriteAnim(CTestAnimDll* aDll, TInt aType) : |
|
27 CAnimProc(aDll, aType) |
|
28 { |
|
29 // No implementation required |
|
30 |
|
31 } |
|
32 |
|
33 CTSpriteAnim::~CTSpriteAnim() |
|
34 { |
|
35 WriteLog(_L("~CTSpriteAnim")); |
|
36 } |
|
37 |
|
38 void CTSpriteAnim::ConstructL(TAny *aArgs) |
|
39 { |
|
40 WriteLog(_L("CTSpriteAnim::ConstructL")); |
|
41 ConstructWinL(aArgs, iFunctions); |
|
42 |
|
43 // screen size |
|
44 iFunctions->ScreenDevice()->GetDrawRect(iScreenSize); |
|
45 } |
|
46 void CTSpriteAnim::Redraw() |
|
47 { |
|
48 WriteLog(_L("CTSpriteAnim::Redraw")); |
|
49 Draw(); |
|
50 } |
|
51 |
|
52 void CTSpriteAnim::Draw() |
|
53 { |
|
54 // signal that the current position has been drawn |
|
55 iDrawn = ETrue; |
|
56 } |
|
57 void CTSpriteAnim::FocusChanged(TBool /*aState*/) |
|
58 { |
|
59 |
|
60 } |
|
61 TInt CTSpriteAnim::CommandReplyL(TInt aOpcode, TAny *aArgs) |
|
62 { |
|
63 switch (aOpcode) |
|
64 { |
|
65 case ECmdSpriteGetSpriteMember: |
|
66 return DoCmdGetSpriteMemberL(); |
|
67 case ECmdSpriteUpdateMember: |
|
68 return DoCmdUpdateMemberL(); |
|
69 case ECmdSpriteActivate: |
|
70 return DoCmdActiveL(); |
|
71 case ECmdSpriteSpriteCanBeSeen: |
|
72 return DoCmdSpriteCanBeSeen(); |
|
73 case ECmdSpriteSizeChangedL: |
|
74 return DoCmdSizeChangeL(); |
|
75 case ECmdSpriteSetPosition: |
|
76 return DoCmdSetPositionL(); |
|
77 default: |
|
78 break; |
|
79 } |
|
80 return CmdReply(iFunctions, aOpcode, aArgs); |
|
81 } |
|
82 void CTSpriteAnim::Command(TInt aOpcode, TAny *aArgs) |
|
83 { |
|
84 CmdReply(iFunctions, aOpcode, aArgs); |
|
85 } |
|
86 void CTSpriteAnim::Animate(TDateTime* /*aDateTime*/) |
|
87 { |
|
88 iLastPoint = iNewPoint; |
|
89 |
|
90 TInt nextpoint=iNewPoint.iX + iStepX; |
|
91 TInt right=iNewPoint.iX + iSize.iWidth; |
|
92 |
|
93 if (right> iScreenSize.iBr.iX ||nextpoint >= iScreenSize.iBr.iX |
|
94 ||iNewPoint.iX<iScreenSize.iTl.iX) |
|
95 iStepX = -iStepX; |
|
96 |
|
97 TInt nexty=iNewPoint.iY + iStepY; |
|
98 TInt bottom=nexty + iSize.iHeight; |
|
99 |
|
100 if (bottom> iScreenSize.iBr.iY ||nexty >= iScreenSize.iBr.iY ||iNewPoint.iY |
|
101 <iScreenSize.iTl.iY || nexty <= iScreenSize.iTl.iY) |
|
102 iStepY = -iStepY; |
|
103 |
|
104 iNewPoint.iX += iStepX; |
|
105 iNewPoint.iY += iStepY; |
|
106 |
|
107 iSpriteFunctions->SetPosition(iNewPoint); |
|
108 |
|
109 RecordAnimTime(); |
|
110 |
|
111 TInt interval=(iAnimTime[KAnimTimeSize-1]-iAnimTime[KAnimTimeSize-2])/1000; |
|
112 |
|
113 TBuf<100> buf; |
|
114 buf.Format(_L("CTSpriteAnim::Animate interval=%d x=%d y=%d"), |
|
115 interval,iNewPoint.iX,iNewPoint.iY); |
|
116 |
|
117 WriteLog(buf); |
|
118 } |
|
119 |
|
120 void CTSpriteAnim::Compare() |
|
121 { |
|
122 // compare |
|
123 const CFbsScreenDevice* scdev=iFunctions->ScreenDevice(); |
|
124 |
|
125 TBool compare=scdev->RectCompare(TRect(iNewPoint, iSize), *scdev, TRect( |
|
126 TPoint(0, 0), iSize)); |
|
127 TBuf<50> buf; |
|
128 buf.Format(_L("CTSpriteAnim::Compare res %d"), |
|
129 compare); |
|
130 WriteLog(buf); |
|
131 } |
|
132 TBool CTSpriteAnim::OfferRawEvent(const TRawEvent& /*aRawEvent*/) |
|
133 { |
|
134 return ETrue; |
|
135 } |
|
136 |
|
137 TInt CTSpriteAnim::DoCmdGetSpriteMemberL() |
|
138 { |
|
139 TInt result = 0; |
|
140 TInt aMember; |
|
141 TPtr8 ptr1((TUint8*)&aMember, sizeof(TInt)); |
|
142 const RMessagePtr2 *msg=iFunctions->Message(); |
|
143 |
|
144 if(msg && !msg->IsNull()) |
|
145 { |
|
146 msg->ReadL(1,ptr1); |
|
147 TSpriteMember* member = iSpriteFunctions->GetSpriteMember(aMember); |
|
148 TPoint point = member->iOffset; |
|
149 TPtr8 ptr2((TUint8*)&point, sizeof(TPoint), sizeof(TPoint)); |
|
150 msg->Write(2, ptr2); |
|
151 |
|
152 } |
|
153 else |
|
154 { |
|
155 result = -1; |
|
156 } |
|
157 return result; |
|
158 |
|
159 } |
|
160 |
|
161 TInt CTSpriteAnim::DoCmdActiveL() |
|
162 { |
|
163 TInt result = 0; |
|
164 TBool aState; |
|
165 TPtr8 ptr3((TUint8*)&aState, sizeof(TBool)); |
|
166 const RMessagePtr2 *msg=iFunctions->Message(); |
|
167 |
|
168 if(msg && !msg->IsNull()) |
|
169 { |
|
170 msg->ReadL(1,ptr3); |
|
171 iSpriteFunctions->Activate(aState); |
|
172 } |
|
173 else |
|
174 { |
|
175 result = -1; |
|
176 } |
|
177 return result; |
|
178 } |
|
179 |
|
180 TInt CTSpriteAnim::DoCmdSetPositionL() |
|
181 { |
|
182 TInt result = 0; |
|
183 TPoint aPoint; |
|
184 TPtr8 ptr6((TUint8*)&aPoint, sizeof(TPoint)); |
|
185 const RMessagePtr2 *msg=iFunctions->Message(); |
|
186 |
|
187 if(msg && !msg->IsNull()) |
|
188 { |
|
189 msg->ReadL(1,ptr6); |
|
190 iSpriteFunctions->SetPosition(aPoint); |
|
191 } |
|
192 else |
|
193 { |
|
194 result = -1; |
|
195 } |
|
196 return result; |
|
197 } |
|
198 |
|
199 TInt CTSpriteAnim::DoCmdSpriteCanBeSeen() |
|
200 { |
|
201 TBool visible = iSpriteFunctions->SpriteCanBeSeen(); |
|
202 TPtr8 ptr((TUint8*)&visible, sizeof(TBool), sizeof(TBool)); |
|
203 iFunctions->Message()->Write(1, ptr); |
|
204 return 0; |
|
205 } |
|
206 |
|
207 TInt CTSpriteAnim::DoCmdUpdateMemberL() |
|
208 { |
|
209 //TInt aMember, const TRect &aRect, TBool aFullUpdate |
|
210 TInt result = 0; |
|
211 TInt aMember; |
|
212 TPtr8 ptr1((TUint8*)&aMember, sizeof(TInt)); |
|
213 |
|
214 TRect aRect; |
|
215 TPtr8 ptr2((TUint8*)&aRect, sizeof(TRect)); |
|
216 |
|
217 TBool aFullUpdate; |
|
218 TPtr8 ptr3((TUint8*)&aFullUpdate, sizeof(TInt)); |
|
219 |
|
220 const RMessagePtr2 *msg=iFunctions->Message(); |
|
221 |
|
222 if(msg && !msg->IsNull()) |
|
223 { |
|
224 msg->ReadL(1,ptr1); |
|
225 msg->ReadL(2,ptr2); |
|
226 msg->ReadL(3,ptr3); |
|
227 iSpriteFunctions->UpdateMember(aMember, aRect, aFullUpdate); |
|
228 } |
|
229 else |
|
230 { |
|
231 result = -1; |
|
232 } |
|
233 return result; |
|
234 } |
|
235 |
|
236 TInt CTSpriteAnim::DoCmdSizeChangeL() |
|
237 { |
|
238 iSpriteFunctions->SizeChangedL(); |
|
239 return 0; |
|
240 } |
|
241 |
|