|
1 /* |
|
2 * Copyright (c) 2006 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: Misc. utils |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // |
|
21 // NOTE THAT THIS FILE IS ALMOST IDENTICAL WITH HUIUTIL.CPP ! |
|
22 // |
|
23 // HuiUtil.h functions are not called from this file because we want alfclient.dll |
|
24 // to not have unnecessary (any) static dependencies to core toolkit hitchcock.dll |
|
25 // (a.k.a huitk.dll, uiaccel.dll,...). There is no other reason to duplicate |
|
26 // this code. |
|
27 // |
|
28 |
|
29 #include "alf/alfutil.h" |
|
30 #include "alf/alftimedvalue.h" |
|
31 |
|
32 #include <e32math.h> |
|
33 #include <hal.h> |
|
34 #include <AknUtils.h> |
|
35 |
|
36 const TReal32 KLengthUnitDivisor = 320.0; |
|
37 |
|
38 /// Character used for separating tags in a tag descriptor. |
|
39 const TInt KTagSeparator = ':'; |
|
40 |
|
41 |
|
42 // Calculates the smallest power-of-two that is equal to or greater than |
|
43 // a value. |
|
44 EXPORT_C TInt AlfUtil::Power2(TInt aValue) |
|
45 { |
|
46 ASSERT(aValue>0); |
|
47 if(aValue<=0) |
|
48 { |
|
49 return 0; |
|
50 } |
|
51 |
|
52 TInt i; |
|
53 for(i = 1; i < aValue && i < KMaxTInt/2; i *= 2) |
|
54 {} |
|
55 return i; |
|
56 } |
|
57 |
|
58 EXPORT_C TInt AlfUtil::Power2RoundDown(TInt aValue) |
|
59 { |
|
60 ASSERT(aValue>0); |
|
61 if(aValue <= 0) |
|
62 { |
|
63 return 0; |
|
64 } |
|
65 |
|
66 TInt i = 1; |
|
67 for(; (i * 4 <= aValue) && (i < KMaxTInt/4); i *= 4) |
|
68 {} |
|
69 for(; (i * 2 <= aValue) && (i < KMaxTInt/2); i *= 2) |
|
70 {} |
|
71 return i; |
|
72 } |
|
73 |
|
74 |
|
75 EXPORT_C TReal32 AlfUtil::Interpolate(TReal32 aPos, TReal32 aMin, TReal32 aMax) __SOFTFP |
|
76 { |
|
77 aPos = Max(0.f, aPos); |
|
78 aPos = Min(aPos, 1.f); |
|
79 return (1 - aPos) * aMin + aPos * aMax; |
|
80 } |
|
81 |
|
82 |
|
83 EXPORT_C void AlfUtil::WrapValue(TReal32& aValue, TReal32 aLow, TReal32 aHigh) __SOFTFP |
|
84 { |
|
85 TReal32 segments = 0; |
|
86 TReal32 length = aHigh - aLow; |
|
87 |
|
88 if(length <= 0) |
|
89 { |
|
90 aValue = aLow; |
|
91 return; |
|
92 } |
|
93 |
|
94 if(aValue < aLow) |
|
95 { |
|
96 // Wrap from below. |
|
97 segments = (aLow - aValue) / length; |
|
98 aValue += (TInt(segments) + 1) * length; |
|
99 } |
|
100 else if(aValue >= aHigh) |
|
101 { |
|
102 // Wrap from above. |
|
103 segments = (aValue - aHigh) / length; |
|
104 aValue -= (TInt(segments) + 1) * length; |
|
105 } |
|
106 else |
|
107 { |
|
108 // for PC lint |
|
109 } |
|
110 } |
|
111 |
|
112 |
|
113 EXPORT_C TInt AlfUtil::RandomInt(TInt aMin, TInt aMax) |
|
114 { |
|
115 TUint32 random = Math::Random(); |
|
116 TUint range = aMax - aMin; |
|
117 if(range > 0) |
|
118 { |
|
119 return aMin + (random % (range + 1)); |
|
120 } |
|
121 else |
|
122 { |
|
123 return aMin; |
|
124 } |
|
125 } |
|
126 |
|
127 |
|
128 EXPORT_C TReal32 AlfUtil::RandomReal(TReal32 aMin, TReal32 aMax) __SOFTFP |
|
129 { |
|
130 /** @todo Could use Math::FRand(). */ |
|
131 TReal32 random = RandomInt(0, 10000000) / 10000000.0; |
|
132 return aMin + (aMax - aMin) * random; |
|
133 } |
|
134 |
|
135 |
|
136 EXPORT_C TUint AlfUtil::FreeMemory(TUint* aTotalMemory) |
|
137 { |
|
138 TInt total = 0; |
|
139 TInt free = 0; |
|
140 |
|
141 HAL::Get(HALData::EMemoryRAM, total); |
|
142 HAL::Get(HALData::EMemoryRAMFree, free); |
|
143 if(aTotalMemory) |
|
144 { |
|
145 *aTotalMemory = total; |
|
146 } |
|
147 return free; |
|
148 } |
|
149 |
|
150 |
|
151 EXPORT_C TSize AlfUtil::ScreenSize() |
|
152 { |
|
153 TSize screenSize(320, 240); |
|
154 |
|
155 AknLayoutUtils::LayoutMetricsSize(AknLayoutUtils::EScreen, screenSize); |
|
156 |
|
157 return screenSize; |
|
158 } |
|
159 |
|
160 |
|
161 EXPORT_C CFont* AlfUtil::NearestFontInTwipsL(const TFontSpec& aFontSpec) |
|
162 { |
|
163 /// @todo Accessing the screen device during a display resizing event may |
|
164 /// result in a font that is suitable for the display size that |
|
165 /// was in use prior to the resize. Probably we should use |
|
166 /// AknLayoutUtils here. |
|
167 |
|
168 CFont* font = NULL; |
|
169 CWsScreenDevice* screenDev = CCoeEnv::Static()->ScreenDevice(); |
|
170 User::LeaveIfError( screenDev->GetNearestFontInTwips(font, aFontSpec) ); |
|
171 return font; |
|
172 } |
|
173 |
|
174 |
|
175 EXPORT_C void AlfUtil::ReleaseFont(CFont* aFont) |
|
176 { |
|
177 CCoeEnv::Static()->ScreenDevice()->ReleaseFont(aFont); |
|
178 } |
|
179 |
|
180 |
|
181 EXPORT_C TReal32 AlfUtil::LengthUnit() __SOFTFP |
|
182 { |
|
183 return Max(ScreenSize().iWidth, ScreenSize().iHeight) / KLengthUnitDivisor; |
|
184 } |
|
185 |
|
186 |
|
187 EXPORT_C TReal32 AlfUtil::QuickLength(TAlfRealPoint& aVector) __SOFTFP |
|
188 { |
|
189 TReal32 dx = Abs(aVector.iX); |
|
190 TReal32 dy = Abs(aVector.iY); |
|
191 if(dx < dy) |
|
192 { |
|
193 return dx + dy - dx/2; |
|
194 } |
|
195 else |
|
196 { |
|
197 return dx + dy - dy/2; |
|
198 } |
|
199 } |
|
200 |
|
201 |
|
202 EXPORT_C TReal32 AlfUtil::QuickLength(TReal32 aDx, TReal32 aDy) __SOFTFP |
|
203 { |
|
204 TReal32 dx = Abs(aDx); |
|
205 TReal32 dy = Abs(aDy); |
|
206 if(dx < dy) |
|
207 { |
|
208 return dx + dy - dx/2; |
|
209 } |
|
210 else |
|
211 { |
|
212 return dx + dy - dy/2; |
|
213 } |
|
214 } |
|
215 |
|
216 |
|
217 EXPORT_C void AlfUtil::QuickNormalize(TAlfRealPoint& aNormal) |
|
218 { |
|
219 TReal32 approxLength = QuickLength(aNormal); |
|
220 |
|
221 if(approxLength > 0) |
|
222 { |
|
223 aNormal.iX /= approxLength; |
|
224 aNormal.iY /= approxLength; |
|
225 } |
|
226 } |
|
227 |
|
228 |
|
229 EXPORT_C void AlfUtil::QuickNormalize(TReal32 aVector[3]) __SOFTFP |
|
230 { |
|
231 TReal32 approxLength = QuickLength(QuickLength(aVector[0], aVector[1]), aVector[2]); |
|
232 |
|
233 if(approxLength > 0) |
|
234 { |
|
235 aVector[0] /= approxLength; |
|
236 aVector[1] /= approxLength; |
|
237 aVector[2] /= approxLength; |
|
238 } |
|
239 } |
|
240 |
|
241 |
|
242 EXPORT_C void AlfUtil::CrossProduct(const TReal32 aA[3], const TReal32 aB[3], |
|
243 TReal32 aProduct[3]) __SOFTFP |
|
244 { |
|
245 aProduct[0] = aA[1] * aB[2] - aB[1] * aA[2]; |
|
246 aProduct[1] = aA[2] * aB[0] - aB[2] * aA[0]; |
|
247 aProduct[2] = aA[0] * aB[1] - aB[0] * aA[1]; |
|
248 } |
|
249 |
|
250 |
|
251 EXPORT_C void AlfUtil::NormalFromPoints(const TReal32 aPoints[3][3], TReal32 aNormal[3]) __SOFTFP |
|
252 { |
|
253 TReal32 vectors[2][3]; |
|
254 TInt i; |
|
255 |
|
256 for(i = 0; i < 3; ++i) |
|
257 { |
|
258 vectors[0][i] = aPoints[0][i] - aPoints[1][i]; |
|
259 vectors[1][i] = aPoints[0][i] - aPoints[2][i]; |
|
260 } |
|
261 |
|
262 CrossProduct(vectors[0], vectors[1], aNormal); |
|
263 QuickNormalize(aNormal); |
|
264 } |
|
265 |
|
266 |
|
267 EXPORT_C void AlfUtil::ShadowMatrix(const TReal32 aPlanePoint[3], |
|
268 const TReal32 aPlaneNormal[3], |
|
269 const TReal32 aLightPos[4], |
|
270 TReal32 aDestMat[16]) __SOFTFP |
|
271 { |
|
272 TReal32 planeCoeff[4]; |
|
273 TReal32 dot; |
|
274 |
|
275 // Find the plane equation coefficients |
|
276 // Find the first three coefficients the same way we find a normal. |
|
277 //NormalFromPoints(aPoints, planeCoeff); |
|
278 |
|
279 planeCoeff[0] = aPlaneNormal[0]; |
|
280 planeCoeff[1] = aPlaneNormal[1]; |
|
281 planeCoeff[2] = aPlaneNormal[2]; |
|
282 |
|
283 // Find the last coefficient by back substitutions |
|
284 planeCoeff[3] = - ((planeCoeff[0] * aPlanePoint[0]) + (planeCoeff[1] * aPlanePoint[1]) + |
|
285 (planeCoeff[2] * aPlanePoint[2])); |
|
286 |
|
287 // Dot product of plane and light position |
|
288 dot = planeCoeff[0] * aLightPos[0] + planeCoeff[1] * aLightPos[1] + |
|
289 planeCoeff[2] * aLightPos[2] + planeCoeff[3] * aLightPos[3]; |
|
290 |
|
291 // Now do the projection |
|
292 // First column |
|
293 aDestMat[0] = dot - aLightPos[0] * planeCoeff[0]; |
|
294 aDestMat[4] = 0.0f - aLightPos[0] * planeCoeff[1]; |
|
295 aDestMat[8] = 0.0f - aLightPos[0] * planeCoeff[2]; |
|
296 aDestMat[12] = 0.0f - aLightPos[0] * planeCoeff[3]; |
|
297 |
|
298 // Second column |
|
299 aDestMat[1] = 0.0f - aLightPos[1] * planeCoeff[0]; |
|
300 aDestMat[5] = dot - aLightPos[1] * planeCoeff[1]; |
|
301 aDestMat[9] = 0.0f - aLightPos[1] * planeCoeff[2]; |
|
302 aDestMat[13] = 0.0f - aLightPos[1] * planeCoeff[3]; |
|
303 |
|
304 // Third Column |
|
305 aDestMat[2] = 0.0f - aLightPos[2] * planeCoeff[0]; |
|
306 aDestMat[6] = 0.0f - aLightPos[2] * planeCoeff[1]; |
|
307 aDestMat[10] = dot - aLightPos[2] * planeCoeff[2]; |
|
308 aDestMat[14] = 0.0f - aLightPos[2] * planeCoeff[3]; |
|
309 |
|
310 // Fourth Column |
|
311 aDestMat[3] = 0.0f - aLightPos[3] * planeCoeff[0]; |
|
312 aDestMat[7] = 0.0f - aLightPos[3] * planeCoeff[1]; |
|
313 aDestMat[11] = 0.0f - aLightPos[3] * planeCoeff[2]; |
|
314 aDestMat[15] = dot - aLightPos[3] * planeCoeff[3]; |
|
315 } |
|
316 |
|
317 |
|
318 EXPORT_C TReal32 AlfUtil::ColorLightness(const TRgb& aColor) __SOFTFP |
|
319 { |
|
320 TReal32 red = aColor.Red() / 255.0f; |
|
321 TReal32 green = aColor.Red() / 255.0f; |
|
322 TReal32 blue = aColor.Red() / 255.0f; |
|
323 |
|
324 return (red*2 + green*3 + blue) / 6.f; |
|
325 } |
|
326 |
|
327 EXPORT_C void AlfUtil::ScaleFbsBitmapL(const CFbsBitmap & aSrcBitmap, |
|
328 CFbsBitmap & aScaledBitmap) |
|
329 { |
|
330 CFbsDevice* targetdevice = NULL; |
|
331 CFbsBitGc* gc = NULL; |
|
332 // create device for drawing onto the target cropped bitmap area |
|
333 targetdevice = CFbsBitmapDevice::NewL(&aScaledBitmap); |
|
334 CleanupStack::PushL(targetdevice); |
|
335 // create graphics context for drawing |
|
336 User::LeaveIfError(targetdevice->CreateContext(gc)); |
|
337 // Perform downscale using DrawBitmap |
|
338 gc->DrawBitmap(TRect(TPoint(0,0), aScaledBitmap.SizeInPixels()), |
|
339 (const CFbsBitmap *)&aSrcBitmap); |
|
340 delete gc; |
|
341 CleanupStack::PopAndDestroy(targetdevice); |
|
342 } |
|
343 |
|
344 EXPORT_C void AlfUtil::CombineMaskFbsBitmapL(const CFbsBitmap & aSrcBitmap, |
|
345 const CFbsBitmap & aSrcMaskBitmap, |
|
346 CFbsBitmap & aCombinedBitmap) |
|
347 { |
|
348 |
|
349 ASSERT(aCombinedBitmap.DisplayMode() == EColor16MA); |
|
350 ASSERT(aSrcMaskBitmap.DisplayMode() == EGray2 || aSrcMaskBitmap.DisplayMode() == EGray256 || aSrcMaskBitmap.DisplayMode() == EGray16 || aSrcMaskBitmap.DisplayMode() == EGray4); |
|
351 // Resize the target bitmap if needed |
|
352 if (aSrcBitmap.SizeInPixels() != aCombinedBitmap.SizeInPixels()) |
|
353 { |
|
354 aCombinedBitmap.Resize(aSrcBitmap.SizeInPixels()); |
|
355 } |
|
356 |
|
357 // Alternative method to blend manually (SLOW!!): |
|
358 // Apply the alpha mask. |
|
359 TBitmapUtil color((CFbsBitmap*)&aSrcBitmap); |
|
360 TBitmapUtil alpha((CFbsBitmap*)&aSrcMaskBitmap); |
|
361 TBitmapUtil target((CFbsBitmap*)&aCombinedBitmap); |
|
362 color.Begin(TPoint(0, 0)); |
|
363 alpha.Begin(TPoint(0, 0)); |
|
364 target.Begin(TPoint(0, 0)); |
|
365 TSize size(aCombinedBitmap.SizeInPixels()); |
|
366 for(TInt y = 0; y < size.iHeight; ++y) |
|
367 { |
|
368 alpha.SetPos(TPoint(0, y)); |
|
369 color.SetPos(TPoint(0, y)); |
|
370 target.SetPos(TPoint(0, y)); |
|
371 for(TInt x = 0; x < size.iWidth; ++x) |
|
372 { |
|
373 target.SetPixel((color.GetPixel() & 0xffffff) |
|
374 | ((alpha.GetPixel() & 0xff) << 24)); |
|
375 target.IncXPos(); |
|
376 color.IncXPos(); |
|
377 alpha.IncXPos(); |
|
378 } |
|
379 } |
|
380 target.End(); |
|
381 color.End(); |
|
382 alpha.End(); |
|
383 |
|
384 } |
|
385 |
|
386 EXPORT_C void AlfUtil::CropFbsBitmapL(const CFbsBitmap & aSrcBitmap, |
|
387 CFbsBitmap & aCroppedBitmap, |
|
388 TPoint aCropPosition) |
|
389 { |
|
390 CFbsDevice* targetdevice; |
|
391 CFbsBitGc* gc; |
|
392 // create device for drawing onto the target cropped bitmap area |
|
393 targetdevice = CFbsBitmapDevice::NewL(&aCroppedBitmap); |
|
394 CleanupStack::PushL(targetdevice); |
|
395 // create graphics context for drawing |
|
396 User::LeaveIfError(targetdevice->CreateContext(gc)); |
|
397 // Perform cropping bitblit |
|
398 gc->BitBlt(TPoint(0,0), &aSrcBitmap, |
|
399 TRect(aCropPosition, aCroppedBitmap.SizeInPixels())); |
|
400 delete gc; |
|
401 CleanupStack::PopAndDestroy(targetdevice); |
|
402 } |
|
403 |
|
404 EXPORT_C void AlfUtil::ScaleImage(TInt aComponents, |
|
405 const TSize& aSrcSize, |
|
406 const TUint8* aSrcBuffer, |
|
407 const TSize& aDestSize, |
|
408 TUint8* aDestBuffer) |
|
409 { |
|
410 // TODO: if there is actual use for this routine, |
|
411 // there might be better minification filters than bilinear... |
|
412 // anyway, now this routine produced acceptable results |
|
413 // when magnifying also... |
|
414 ASSERT (aDestBuffer && aSrcBuffer); |
|
415 ASSERT (aSrcSize.iWidth > 0 && aSrcSize.iHeight > 0); |
|
416 ASSERT (aDestSize.iWidth > 0 && aDestSize.iHeight > 0); |
|
417 ASSERT (aComponents > 0 && aComponents < 5); |
|
418 |
|
419 TUint32 xScale = ((aSrcSize.iWidth-1) << 16) / aDestSize.iWidth; |
|
420 TUint32 yScale = ((aSrcSize.iHeight-1) << 16) / aDestSize.iHeight; |
|
421 TUint32 height = aDestSize.iHeight; |
|
422 TUint8* srcptr = const_cast<TUint8*>(aSrcBuffer); |
|
423 TUint8* destPtrLimit = aDestBuffer+(aDestSize.iWidth*aComponents); |
|
424 TUint32 y = yScale&0xffff; |
|
425 do |
|
426 { |
|
427 TUint32 fV = y&0xffff; |
|
428 TUint32 x = xScale&0xffff; |
|
429 while(aDestBuffer < destPtrLimit) |
|
430 { |
|
431 |
|
432 TUint32 fU = x&0xffff; |
|
433 for (TInt components = 0; components < aComponents; components++) |
|
434 { |
|
435 TUint32 componenta = srcptr[((x>>16)*aComponents)+components]; |
|
436 TUint32 componentb = srcptr[((x>>16)*aComponents)+aComponents+components]; |
|
437 TUint32 componentc = srcptr[((x>>16)*aComponents)+(aSrcSize.iWidth*aComponents)+components]; |
|
438 TUint32 componentd = srcptr[((x>>16)*aComponents)+(aSrcSize.iWidth*aComponents)+aComponents+components]; |
|
439 |
|
440 TUint32 componentf1 = (componenta+(((fU*((componentb-componenta)))>>16))) & 0xff; |
|
441 TUint32 componentf2 = (componentc+(((fU*((componentd-componentc)))>>16))) & 0xff; |
|
442 TUint32 finalcomponent = (componentf1+(((fV*((componentf2-componentf1)))>>16))) & 0xff; |
|
443 *aDestBuffer++ = (TUint8)finalcomponent; |
|
444 } |
|
445 x+=xScale; |
|
446 } |
|
447 y+=yScale; |
|
448 srcptr = const_cast<TUint8*>(aSrcBuffer)+((y>>16)*(aSrcSize.iWidth*aComponents)); |
|
449 destPtrLimit+=aDestSize.iWidth*aComponents; |
|
450 } |
|
451 while (--height); |
|
452 } |
|
453 |
|
454 EXPORT_C void AlfUtil::CropImage(TInt aComponents, |
|
455 const TSize& aSrcBufferSize, |
|
456 const TUint8* aSrcBuffer, |
|
457 const TPoint& aCropOffset, |
|
458 const TSize& aCroppedSize, |
|
459 TUint8* aDestBuffer) |
|
460 { |
|
461 ASSERT (aDestBuffer && aSrcBuffer); |
|
462 ASSERT (aSrcBufferSize.iWidth > 0 && aSrcBufferSize.iHeight > 0); |
|
463 ASSERT (aCroppedSize.iWidth > 0 && aCroppedSize.iHeight > 0); |
|
464 ASSERT (aCropOffset.iX < aSrcBufferSize.iWidth); |
|
465 ASSERT (aCropOffset.iY < aSrcBufferSize.iHeight); |
|
466 ASSERT (aComponents > 0 && aComponents < 5); |
|
467 |
|
468 TInt targetlinesize = aCroppedSize.iWidth*aComponents; |
|
469 TInt sourcelinesize = aSrcBufferSize.iWidth*aComponents; |
|
470 for (TInt y=0; y<aCroppedSize.iHeight; y++) |
|
471 { |
|
472 // copy line at a time.. |
|
473 TAny * source = (TAny*)((const TUint8*)aSrcBuffer |
|
474 + ((y+aCropOffset.iY)*sourcelinesize) |
|
475 + (aCropOffset.iX * aComponents)); |
|
476 TAny * target = (TAny*)((const TUint8*)aDestBuffer + (y*targetlinesize)); |
|
477 memcpy(target, source, targetlinesize); |
|
478 } |
|
479 |
|
480 } |
|
481 |
|
482 EXPORT_C CFbsBitmap* AlfUtil::ConvertBitmapToDisplayModeLC( const CFbsBitmap& aBitmap, const TDisplayMode& aDisplaymode ) |
|
483 { |
|
484 // Create target bitmap |
|
485 CFbsBitmap* targetBitmap = new CFbsBitmap(); |
|
486 CleanupStack::PushL( targetBitmap ); |
|
487 targetBitmap->Create( aBitmap.SizeInPixels(), aDisplaymode ); |
|
488 |
|
489 // Create bitmap device for target rendering |
|
490 CFbsBitmapDevice* targetDevice = CFbsBitmapDevice::NewL( targetBitmap ); |
|
491 CleanupStack::PushL( targetDevice ); |
|
492 |
|
493 // Create bitmap graphics context |
|
494 CFbsBitGc* bitgc = CFbsBitGc::NewL(); |
|
495 CleanupStack::PushL( bitgc ); |
|
496 bitgc->Activate( targetDevice ); |
|
497 |
|
498 // BitBlt the given bitmap to target device. |
|
499 bitgc->BitBlt( TPoint( 0, 0 ), &aBitmap ); |
|
500 |
|
501 CleanupStack::PopAndDestroy( bitgc ); |
|
502 CleanupStack::PopAndDestroy( targetDevice ); |
|
503 |
|
504 return targetBitmap; |
|
505 } |
|
506 |
|
507 |
|
508 EXPORT_C TBool AlfUtil::TagMatches(const TDesC8& aTagsColonSeparated, const TDesC8& aTag) |
|
509 { |
|
510 TPtrC8 region = aTagsColonSeparated; |
|
511 TPtrC8 tag; |
|
512 TInt index = 0; |
|
513 |
|
514 if(!aTag.Length()) |
|
515 { |
|
516 // No tag specified; doesn't match anything. |
|
517 return EFalse; |
|
518 } |
|
519 |
|
520 while(region.Length() > 0) |
|
521 { |
|
522 // Is there a colon in the region? |
|
523 index = region.Locate(TChar(KTagSeparator)); |
|
524 if(index != KErrNotFound) |
|
525 { |
|
526 // A separator exists in the region. |
|
527 tag.Set(region.Left(index)); |
|
528 region.Set(region.Right(region.Length() - index - 1)); |
|
529 } |
|
530 else |
|
531 { |
|
532 tag.Set(region); |
|
533 region.Set(region.Right(0)); |
|
534 } |
|
535 |
|
536 if(!tag.Compare(aTag)) |
|
537 { |
|
538 // Matches. |
|
539 return ETrue; |
|
540 } |
|
541 } |
|
542 |
|
543 // No match could be found. |
|
544 return EFalse; |
|
545 } |
|
546 |
|
547 |
|
548 void AlfUtil::Assert(TBool aCondition) |
|
549 { |
|
550 // Assert that the passed condition is true. |
|
551 if (aCondition == EFalse) |
|
552 { |
|
553 // You can breakpoint here to trap asserts. |
|
554 ASSERT(EFalse); |
|
555 } |
|
556 } |
|
557 |
|
558 |
|
559 TInt AlfUtil::RoundFloatToInt(TReal32 aVal) |
|
560 { |
|
561 return (aVal < 0 ? (TInt)(aVal - 0.5f) : (TInt)(aVal + 0.5f)); |
|
562 } |
|
563 |
|
564 // --------------------------------------------------------------------------- |
|
565 // DEPRECATED: Gets the Avkon Skin TAknsItemID based on string version |
|
566 // --------------------------------------------------------------------------- |
|
567 // |
|
568 EXPORT_C TAknsItemID AlfUtil::ThemeItemIdL( CAlfEnv& /*aEnv*/, const TDesC& /*aSkinId*/) |
|
569 { |
|
570 return KAknsIIDNone; |
|
571 } |