|
1 /* |
|
2 * Copyright (c) 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: Class to store physics related data in forms. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "CMIDForm.h" |
|
20 #include "CMIDFormPhysics.h" |
|
21 // #include "MMIDLcduiPhysicsInterface.h" |
|
22 // used for retrieving CR repository codes |
|
23 #include <centralrepository.h> |
|
24 |
|
25 // ======== MEMBER FUNCTIONS ======== |
|
26 |
|
27 // --------------------------------------------------------------------------- |
|
28 // CMIDFormPhysics::CMIDFormPhysics |
|
29 // --------------------------------------------------------------------------- |
|
30 // |
|
31 CMIDFormPhysics::CMIDFormPhysics(CMIDForm& aParent) : |
|
32 iParent(aParent) |
|
33 { |
|
34 } |
|
35 |
|
36 // --------------------------------------------------------------------------- |
|
37 // CMIDFormPhysics::ConstructL |
|
38 // --------------------------------------------------------------------------- |
|
39 // |
|
40 //typedef MMIDLcduiPhysicsInterface* (*GetInstance)(CCoeControl*, MMIDLcduiPhysicsObserver*); |
|
41 void CMIDFormPhysics::ConstructL() |
|
42 { |
|
43 _LIT(KDllName, "lcduiphysicswrap"); |
|
44 |
|
45 TInt status = iPluginLoader.Load(KDllName); |
|
46 if (status == KErrNone) |
|
47 { |
|
48 GetInstance getInstanceL = (GetInstance)iPluginLoader.Lookup(1); |
|
49 iPhysics = getInstanceL(&iParent, this); |
|
50 } |
|
51 } |
|
52 |
|
53 // --------------------------------------------------------------------------- |
|
54 // CMIDFormPhysics::NewL |
|
55 // --------------------------------------------------------------------------- |
|
56 // |
|
57 CMIDFormPhysics* CMIDFormPhysics::NewL(CMIDForm& aParent) |
|
58 { |
|
59 CMIDFormPhysics* self = new(ELeave) CMIDFormPhysics(aParent); |
|
60 CleanupStack::PushL(self); |
|
61 self->ConstructL(); |
|
62 CleanupStack::Pop(self); |
|
63 return self; |
|
64 } |
|
65 |
|
66 // --------------------------------------------------------------------------- |
|
67 // CMIDFormPhysics::~CMIDFormPhysics |
|
68 // --------------------------------------------------------------------------- |
|
69 // |
|
70 CMIDFormPhysics::~CMIDFormPhysics() |
|
71 { |
|
72 delete iPhysics; |
|
73 iPluginLoader.Close(); |
|
74 } |
|
75 |
|
76 TBool CMIDFormPhysics::FeatureEnabled() |
|
77 { |
|
78 #ifdef RD_JAVA_S60_RELEASE_9_2 |
|
79 return ETrue; |
|
80 #else |
|
81 // Copied from aknphysicscrkeys.h |
|
82 const TUid KCRUidAknPhysicsSettings = { 0x20021192 }; |
|
83 const TInt KFeatureEnabled(0x00000009); |
|
84 |
|
85 CRepository* cenRep = NULL; |
|
86 TRAPD(err, cenRep = CRepository::NewL(KCRUidAknPhysicsSettings)) |
|
87 if (err || !cenRep) |
|
88 { |
|
89 return EFalse; |
|
90 } |
|
91 TBool featureEnabled(EFalse); |
|
92 TInt retValue = cenRep->Get(KFeatureEnabled, featureEnabled); |
|
93 delete cenRep; |
|
94 |
|
95 if (retValue == KErrNone) |
|
96 { |
|
97 return featureEnabled; |
|
98 } |
|
99 else |
|
100 { |
|
101 return EFalse; |
|
102 } |
|
103 #endif |
|
104 } |
|
105 |
|
106 // --------------------------------------------------------------------------- |
|
107 // CMIDFormPhysics::InitPhysicsL |
|
108 // --------------------------------------------------------------------------- |
|
109 // |
|
110 void CMIDFormPhysics::InitPhysicsL(const TSize& aWorldSize, |
|
111 const TSize& aViewSize, const TPoint& aViewCenter) |
|
112 { |
|
113 if (iPhysics) |
|
114 { |
|
115 iPhysics->InitPhysicsL(aWorldSize, aViewSize, EFalse); |
|
116 iViewCenter = aViewCenter; |
|
117 iWorldSize = aWorldSize; |
|
118 iViewSize = aViewSize; |
|
119 } |
|
120 } |
|
121 |
|
122 // --------------------------------------------------------------------------- |
|
123 // CMIDFormPhysics::Stop |
|
124 // --------------------------------------------------------------------------- |
|
125 // |
|
126 void CMIDFormPhysics::Stop() |
|
127 { |
|
128 if (iPhysics) |
|
129 { |
|
130 iPhysics->StopPhysics(); |
|
131 iPhysics->ResetFriction(); |
|
132 } |
|
133 } |
|
134 |
|
135 // --------------------------------------------------------------------------- |
|
136 // CMIDFormPhysics::StartFlick |
|
137 // --------------------------------------------------------------------------- |
|
138 // |
|
139 TBool CMIDFormPhysics::StartFlick(const TPoint& aLength, TTime aDuration) |
|
140 { |
|
141 if (iPhysics) |
|
142 { |
|
143 TPoint drag(aLength); |
|
144 iPhysics->StartFlick(drag, aDuration); |
|
145 return ETrue; |
|
146 } |
|
147 |
|
148 PhysicEmulationEnded(); |
|
149 return EFalse; |
|
150 } |
|
151 |
|
152 |
|
153 // --------------------------------------------------------------------------- |
|
154 // CMIDFormPhysics::HighlightDelay |
|
155 // --------------------------------------------------------------------------- |
|
156 // |
|
157 TInt CMIDFormPhysics::HighlightDelay() const |
|
158 { |
|
159 if (iPhysics) |
|
160 { |
|
161 return iPhysics->HighlightTimeout(); |
|
162 } |
|
163 else |
|
164 { |
|
165 return 0; |
|
166 } |
|
167 } |
|
168 |
|
169 // --------------------------------------------------------------------------- |
|
170 // CMIDFormPhysics::DragThreshold |
|
171 // --------------------------------------------------------------------------- |
|
172 // |
|
173 TInt CMIDFormPhysics::DragThreshold() const |
|
174 { |
|
175 if (iPhysics) |
|
176 { |
|
177 return iPhysics->DragThreshold(); |
|
178 } |
|
179 else |
|
180 { |
|
181 return 0; |
|
182 } |
|
183 } |
|
184 |
|
185 // --------------------------------------------------------------------------- |
|
186 // CMIDFormPhysics::ViewdSize |
|
187 // --------------------------------------------------------------------------- |
|
188 // |
|
189 TSize CMIDFormPhysics::ViewSize() const |
|
190 { |
|
191 return iViewSize; |
|
192 } |
|
193 |
|
194 // --------------------------------------------------------------------------- |
|
195 // CMIDFormPhysics::SetPanningPosition |
|
196 // --------------------------------------------------------------------------- |
|
197 // |
|
198 void CMIDFormPhysics::SetPanningPosition(const TPoint& aPosition) |
|
199 { |
|
200 if (iPhysics) |
|
201 { |
|
202 iPhysics->RegisterPanningPosition(aPosition); |
|
203 } |
|
204 } |
|
205 |
|
206 // --------------------------------------------------------------------------- |
|
207 // CMIDFormPhysics::ViewPositionChanged |
|
208 // --------------------------------------------------------------------------- |
|
209 // |
|
210 void CMIDFormPhysics::ViewPositionChanged(const TPoint& aNewPosition, TBool aDrawNow, TUint aFlags) |
|
211 { |
|
212 if (!PhysicsAllowed()) |
|
213 { |
|
214 return; |
|
215 } |
|
216 |
|
217 TInt delta = iViewCenter.iY - aNewPosition.iY; |
|
218 |
|
219 iViewCenter = aNewPosition; |
|
220 |
|
221 iParent.HandlePhysicsScroll(delta, aDrawNow, aFlags); |
|
222 } |
|
223 |
|
224 // --------------------------------------------------------------------------- |
|
225 // CMIDFormPhysics::PhysicEmulationEnded |
|
226 // --------------------------------------------------------------------------- |
|
227 // |
|
228 void CMIDFormPhysics::PhysicEmulationEnded() |
|
229 { |
|
230 iParent.PhysicsScrollingEnd(); |
|
231 } |
|
232 |
|
233 // --------------------------------------------------------------------------- |
|
234 // CMIDFormPhysics::ViewPosition |
|
235 // --------------------------------------------------------------------------- |
|
236 // |
|
237 TPoint CMIDFormPhysics::ViewPosition() const |
|
238 { |
|
239 return iViewCenter; |
|
240 } |
|
241 |
|
242 // --------------------------------------------------------------------------- |
|
243 // CMIDFormPhysics::CanBeStopped |
|
244 // --------------------------------------------------------------------------- |
|
245 // |
|
246 TBool CMIDFormPhysics::CanBeStopped() const |
|
247 { |
|
248 if (iPhysics) |
|
249 { |
|
250 return iPhysics->CanBeStopped(); |
|
251 } |
|
252 else |
|
253 { |
|
254 return ETrue; |
|
255 } |
|
256 } |
|
257 // --------------------------------------------------------------------------- |
|
258 // CMIDFormPhysics::PhysicsAllowed |
|
259 // --------------------------------------------------------------------------- |
|
260 // |
|
261 TBool CMIDFormPhysics::PhysicsAllowed() const |
|
262 { |
|
263 if (iPhysics) |
|
264 { |
|
265 return ETrue; |
|
266 } |
|
267 else |
|
268 { |
|
269 return EFalse; |
|
270 } |
|
271 } |