|
1 /* |
|
2 * Copyright (c) 2002-2007 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: Implementation for skinnable clock face. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // SYSTEM INCLUDE FILES |
|
20 #include <e32math.h> |
|
21 #include <bitdev.h> |
|
22 #include <AknsUtils.h> |
|
23 #include <AknIconUtils.h> |
|
24 #include <aknlayoutscalable_apps.cdl.h> |
|
25 #include <aknlayoutscalable_avkon.cdl.h> |
|
26 |
|
27 // USER INCLUDE FILES |
|
28 #include "AknUtils.h" |
|
29 #include "AknSkinnableClockFace.h" |
|
30 #include "AknStatuspaneUtils.h" |
|
31 |
|
32 // LOCAL CONSTANTS AND MACROS |
|
33 _LIT( KAmPm, "%B" ); |
|
34 |
|
35 // ============================ MEMBER FUNCTIONS =============================== |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // CAknSkinnableClockFaceDigital::CAknSkinnableClockFaceDigital |
|
39 // C++ default constructor can NOT contain any code, that |
|
40 // might leave. |
|
41 // ----------------------------------------------------------------------------- |
|
42 // |
|
43 CAknSkinnableClockFaceDigital::CAknSkinnableClockFaceDigital() |
|
44 { |
|
45 } |
|
46 |
|
47 // ----------------------------------------------------------------------------- |
|
48 // CAknSkinnableClockFaceDigital::ConstructL |
|
49 // Symbian 2nd phase constructor can leave. |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 void CAknSkinnableClockFaceDigital::ConstructL() |
|
53 { |
|
54 } |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // CAknSkinnableClockFaceDigital::NewL |
|
58 // Two-phased constructor. |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 CAknSkinnableClockFaceDigital* CAknSkinnableClockFaceDigital::NewL() |
|
62 { |
|
63 CAknSkinnableClockFaceDigital* self = |
|
64 new ( ELeave ) CAknSkinnableClockFaceDigital; |
|
65 |
|
66 CleanupStack::PushL( self ); |
|
67 self->ConstructL(); |
|
68 CleanupStack::Pop( self ); |
|
69 |
|
70 return self; |
|
71 } |
|
72 |
|
73 // ----------------------------------------------------------------------------- |
|
74 // Destructor |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
|
77 CAknSkinnableClockFaceDigital::~CAknSkinnableClockFaceDigital() |
|
78 { |
|
79 } |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // Helper method to check if latin digits should be used in the clock |
|
83 // even if locale data defines otherwise. |
|
84 // ----------------------------------------------------------------------------- |
|
85 // |
|
86 inline TBool IsNonLatinDigitsUsed() |
|
87 { |
|
88 TLanguage uiLanguage = AknLangUtils::UserLanguage(); |
|
89 TLocale locale; |
|
90 locale.Refresh(); |
|
91 TDigitType digitType( locale.DigitType() ); |
|
92 |
|
93 if ( uiLanguage == ELangUrdu ) |
|
94 { |
|
95 return EFalse; |
|
96 } |
|
97 |
|
98 return ( AknTextUtils::DigitModeQuery() && |
|
99 digitType != EDigitTypeDevanagari ); |
|
100 } |
|
101 |
|
102 // ----------------------------------------------------------------------------- |
|
103 // CAknSkinnableClockFaceDigital::DrawTimeToBitmap |
|
104 // (other items were commented in a header). |
|
105 // ----------------------------------------------------------------------------- |
|
106 // |
|
107 void CAknSkinnableClockFaceDigital::DrawTimeToBitmapL( TRect& aRect, |
|
108 CBitmapContext& aBufferGc, |
|
109 TTime& aTime ) |
|
110 { |
|
111 TRect bufferRect( aRect ); |
|
112 |
|
113 TAknWindowLineLayout smallClockPaneLayout( |
|
114 AknLayoutScalable_Apps::popup_clock_digital_window() ); |
|
115 |
|
116 TBool smallClock( bufferRect.Width() <= smallClockPaneLayout.iW ); |
|
117 |
|
118 TAknLayoutText amPmIndication; |
|
119 |
|
120 TBool isExtendedLayoutActive( AknStatuspaneUtils::ExtendedLayoutActive() ); |
|
121 TBool isIdleLayoutActive( AknStatuspaneUtils::IdleLayoutActive() ); |
|
122 |
|
123 if ( isExtendedLayoutActive && |
|
124 isIdleLayoutActive ) |
|
125 { |
|
126 amPmIndication.LayoutText( |
|
127 bufferRect, |
|
128 AknLayoutScalable_Avkon::popup_clock_digital_window_t1( 1 ) ); |
|
129 |
|
130 } |
|
131 else if ( smallClock ) |
|
132 { |
|
133 amPmIndication.LayoutText( |
|
134 bufferRect, |
|
135 AknLayoutScalable_Apps::popup_clock_digital_window_t1() ); |
|
136 } |
|
137 else |
|
138 { |
|
139 amPmIndication.LayoutText( |
|
140 bufferRect, |
|
141 AknLayoutScalable_Apps::popup_clock_digital_window_cp02_t1( 0 ) ); |
|
142 } |
|
143 |
|
144 TAknLayoutRect qsnCpClockDigitalLine[4]; |
|
145 |
|
146 if ( isExtendedLayoutActive && |
|
147 isIdleLayoutActive ) |
|
148 { |
|
149 qsnCpClockDigitalLine[0].LayoutRect( |
|
150 bufferRect, |
|
151 AknLayoutScalable_Avkon::clock_digital_number_pane( 2 ) ); |
|
152 |
|
153 qsnCpClockDigitalLine[1].LayoutRect( |
|
154 bufferRect, |
|
155 AknLayoutScalable_Avkon::clock_digital_number_pane_cp03( 2 ) ); |
|
156 |
|
157 qsnCpClockDigitalLine[2].LayoutRect( |
|
158 bufferRect, |
|
159 AknLayoutScalable_Avkon::clock_digital_number_pane_cp02( 2 ) ); |
|
160 |
|
161 qsnCpClockDigitalLine[3].LayoutRect( |
|
162 bufferRect, |
|
163 AknLayoutScalable_Avkon::clock_digital_number_pane_cp04( 2 ) ); |
|
164 } |
|
165 else if ( smallClock ) |
|
166 { |
|
167 TAknWindowComponentLayout digitLayout( |
|
168 AknLayoutScalable_Apps::clock_digital_number_pane_g1() ); |
|
169 |
|
170 qsnCpClockDigitalLine[0].LayoutRect( |
|
171 bufferRect, |
|
172 TAknWindowComponentLayout::Compose( |
|
173 AknLayoutScalable_Apps::clock_digital_number_pane( 0 ), |
|
174 digitLayout ) ); |
|
175 |
|
176 qsnCpClockDigitalLine[1].LayoutRect( |
|
177 bufferRect, |
|
178 TAknWindowComponentLayout::Compose( |
|
179 AknLayoutScalable_Apps::clock_digital_number_pane_cp03( 0 ), |
|
180 digitLayout ) ); |
|
181 |
|
182 qsnCpClockDigitalLine[2].LayoutRect( |
|
183 bufferRect, |
|
184 TAknWindowComponentLayout::Compose( |
|
185 AknLayoutScalable_Apps::clock_digital_number_pane_cp02( 0 ), |
|
186 digitLayout ) ); |
|
187 |
|
188 qsnCpClockDigitalLine[3].LayoutRect( |
|
189 bufferRect, |
|
190 TAknWindowComponentLayout::Compose( |
|
191 AknLayoutScalable_Apps::clock_digital_number_pane_cp04( 0 ), |
|
192 digitLayout ) ); |
|
193 } |
|
194 else |
|
195 { |
|
196 TAknWindowComponentLayout digitLayout( |
|
197 AknLayoutScalable_Apps::clock_digital_number_pane_cp10_g1(1) ); |
|
198 |
|
199 qsnCpClockDigitalLine[0].LayoutRect( |
|
200 bufferRect, |
|
201 TAknWindowComponentLayout::Compose( |
|
202 AknLayoutScalable_Apps::clock_digital_number_pane_cp10( 0 ), |
|
203 digitLayout ) ); |
|
204 |
|
205 qsnCpClockDigitalLine[1].LayoutRect( |
|
206 bufferRect, |
|
207 TAknWindowComponentLayout::Compose( |
|
208 AknLayoutScalable_Apps::clock_digital_number_pane_cp11( 0 ), |
|
209 digitLayout ) ); |
|
210 |
|
211 qsnCpClockDigitalLine[2].LayoutRect( |
|
212 bufferRect, |
|
213 TAknWindowComponentLayout::Compose( |
|
214 AknLayoutScalable_Apps::clock_digital_number_pane_cp12( 0 ), |
|
215 digitLayout ) ); |
|
216 |
|
217 qsnCpClockDigitalLine[3].LayoutRect( |
|
218 bufferRect, |
|
219 TAknWindowComponentLayout::Compose( |
|
220 AknLayoutScalable_Apps::clock_digital_number_pane_cp13( 0 ), |
|
221 digitLayout ) ); |
|
222 } |
|
223 |
|
224 TAknLayoutRect qsnCpClockDigitalSeparator; |
|
225 |
|
226 if ( isExtendedLayoutActive && |
|
227 isIdleLayoutActive ) |
|
228 { |
|
229 qsnCpClockDigitalSeparator.LayoutRect( |
|
230 bufferRect, |
|
231 AknLayoutScalable_Avkon::clock_digital_separator_pane( 2 ) ); |
|
232 } |
|
233 else if ( smallClock ) |
|
234 { |
|
235 qsnCpClockDigitalSeparator.LayoutRect( |
|
236 bufferRect, |
|
237 TAknWindowComponentLayout::Compose( |
|
238 AknLayoutScalable_Apps::clock_digital_separator_pane( 0 ), |
|
239 AknLayoutScalable_Apps::clock_digital_separator_pane_g1() ) ); |
|
240 } |
|
241 else |
|
242 { |
|
243 qsnCpClockDigitalSeparator.LayoutRect( |
|
244 bufferRect, |
|
245 TAknWindowComponentLayout::Compose( |
|
246 AknLayoutScalable_Apps::clock_digital_separator_pane_cp10( 0 ), |
|
247 AknLayoutScalable_Apps::clock_digital_separator_pane_cp10_g1(1) ) ); |
|
248 } |
|
249 |
|
250 TDateTime dateTime( aTime.DateTime() ); |
|
251 |
|
252 TInt hour = dateTime.Hour(); |
|
253 TInt minute = dateTime.Minute(); |
|
254 TBool time24h = ETrue; |
|
255 if( TLocale().TimeFormat() == ETime12 ) |
|
256 { |
|
257 time24h = EFalse; |
|
258 if ( hour < 1 ) |
|
259 { |
|
260 hour = 12; |
|
261 } |
|
262 if ( hour > 12 ) |
|
263 { |
|
264 hour -= 12; |
|
265 } |
|
266 } |
|
267 |
|
268 TInt digits[4]; |
|
269 digits[0] = hour / 10; |
|
270 digits[1] = hour % 10; |
|
271 digits[2] = minute / 10; |
|
272 digits[3] = minute % 10; |
|
273 |
|
274 if( !digits[0] && !time24h ) |
|
275 { |
|
276 digits[0] = -1; |
|
277 } |
|
278 |
|
279 TInt delimiterDigit = |
|
280 EAknsMinorQsnCpClockDigitalColon - EAknsMinorQsnCpClockDigitalZero; |
|
281 if( TLocale().TimeSeparator(1) == TChar('.') ) |
|
282 { |
|
283 delimiterDigit = |
|
284 EAknsMinorQsnCpClockDigitalStop - EAknsMinorQsnCpClockDigitalZero; |
|
285 } |
|
286 |
|
287 // First, blit with soft masks (w/ halo) |
|
288 |
|
289 for( TInt i = 0; i < 4; i++ ) |
|
290 { |
|
291 if( digits[i] >= 0 ) |
|
292 { |
|
293 BlendDigitL( |
|
294 aBufferGc, |
|
295 qsnCpClockDigitalLine[i].Rect(), |
|
296 digits[i], |
|
297 EFalse ); |
|
298 } |
|
299 } |
|
300 |
|
301 // Separator character |
|
302 BlendDigitL( |
|
303 aBufferGc, |
|
304 qsnCpClockDigitalSeparator.Rect(), |
|
305 delimiterDigit, |
|
306 EFalse ); |
|
307 |
|
308 // Then, re-blit with hard masks. |
|
309 // This removes any halo bleeded to adjacent digits. |
|
310 |
|
311 BlendDigitL( aBufferGc, |
|
312 qsnCpClockDigitalSeparator.Rect(), delimiterDigit, ETrue ); |
|
313 |
|
314 for( TInt i = 0; i < 4; i++ ) |
|
315 { |
|
316 if( digits[i] >= 0 ) |
|
317 { |
|
318 BlendDigitL(// bufferRect, |
|
319 aBufferGc, |
|
320 qsnCpClockDigitalLine[i].Rect(), |
|
321 digits[i], |
|
322 ETrue ); |
|
323 } |
|
324 } |
|
325 |
|
326 if( !time24h ) |
|
327 { |
|
328 TBuf<KMaxAmPmName + 1> amPmText; |
|
329 aTime.FormatL( amPmText, KAmPm ); |
|
330 TRgb ampmColor = KRgbBlack; |
|
331 AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), |
|
332 ampmColor, |
|
333 KAknsIIDQsnIconColors, |
|
334 EAknsCIQsnIconColorsCG1 ); |
|
335 amPmIndication.DrawText( aBufferGc, amPmText, ETrue, ampmColor); |
|
336 } |
|
337 } |
|
338 |
|
339 // ----------------------------------------------------------------------------- |
|
340 // CAknSkinnableClockFaceDigital::BlendDigitL |
|
341 // (other items were commented in a header). |
|
342 // ----------------------------------------------------------------------------- |
|
343 // |
|
344 void CAknSkinnableClockFaceDigital::BlendDigitL( CBitmapContext& aBufferGc, |
|
345 const TRect& aRect, |
|
346 const TInt aDigit, |
|
347 const TBool aHardMask ) |
|
348 { |
|
349 |
|
350 |
|
351 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
352 |
|
353 TInt baseID = EAknsMinorQsnCpClockDigitalZero; |
|
354 TInt baseSoftMaskID = EAknsMinorQsnCpClockDigitalZeroMaskSoft; // Only for bitmaps |
|
355 TInt baseHardMaskID = EAknsMinorQsnCpClockDigitalZeroMaskHard; // Only for SVGs |
|
356 |
|
357 if( IsNonLatinDigitsUsed() ) |
|
358 { |
|
359 // Arabic-Indic digits |
|
360 baseID = EAknsMinorQsnCpClockDigitalAhZero; |
|
361 baseSoftMaskID = EAknsMinorQsnCpClockDigitalAhZeroMaskSoft; |
|
362 baseHardMaskID = EAknsMinorQsnCpClockDigitalAhZeroMaskHard; |
|
363 } |
|
364 |
|
365 TAknsItemID iid; |
|
366 CFbsBitmap* digitBitmap = NULL; |
|
367 CFbsBitmap* digitDirectMask = NULL; |
|
368 CFbsBitmap* digitSeparateMask = NULL; |
|
369 |
|
370 TBool separateMaskIsSoft( ETrue ); |
|
371 TInt separateMaskID = baseSoftMaskID + aDigit; |
|
372 |
|
373 iid.Set( EAknsMajorSkin, baseID + aDigit ); |
|
374 AknsUtils::GetCachedMaskedBitmap( skin, iid, digitBitmap, digitDirectMask ); |
|
375 if( digitBitmap ) |
|
376 { |
|
377 // Legacy digits |
|
378 if( AknIconUtils::IsMifIcon( digitBitmap ) ) |
|
379 { |
|
380 separateMaskIsSoft = EFalse; |
|
381 separateMaskID = baseHardMaskID + aDigit; |
|
382 } |
|
383 |
|
384 iid.Set( EAknsMajorSkin, separateMaskID ); |
|
385 digitSeparateMask = AknsUtils::GetCachedBitmap( skin, iid ); |
|
386 } |
|
387 else |
|
388 { |
|
389 // New digits |
|
390 baseID = EAknsMinorQsnCpClockDigitalNewZero; |
|
391 baseHardMaskID = EAknsMinorQsnCpClockDigitalNewZeroShape; |
|
392 |
|
393 TLocale locale; |
|
394 locale.Refresh(); |
|
395 TDigitType digitType( locale.DigitType() ); |
|
396 if( IsNonLatinDigitsUsed() ) |
|
397 { |
|
398 // Arabic-Indic digits |
|
399 baseID = EAknsMinorQsnCpClockDigitalAhNewZero; |
|
400 baseHardMaskID = EAknsMinorQsnCpClockDigitalAhNewZeroShape; |
|
401 } |
|
402 |
|
403 iid.Set( EAknsMajorSkin, baseID + aDigit ); |
|
404 AknsUtils::GetCachedMaskedBitmap( skin, iid, digitBitmap, digitDirectMask ); |
|
405 |
|
406 if( !digitBitmap ) |
|
407 { |
|
408 // No digit to render |
|
409 return; |
|
410 } |
|
411 |
|
412 separateMaskIsSoft = EFalse; |
|
413 separateMaskID = baseHardMaskID + aDigit; |
|
414 |
|
415 iid.Set( EAknsMajorSkin, separateMaskID ); |
|
416 digitSeparateMask = AknsUtils::GetCachedBitmap( skin, iid ); |
|
417 } |
|
418 |
|
419 TScaleMode scalemode( EAspectRatioNotPreserved ); |
|
420 User::LeaveIfError( AknIconUtils::SetSize( |
|
421 digitBitmap, aRect.Size(), |
|
422 scalemode ) ); |
|
423 |
|
424 if( digitSeparateMask ) |
|
425 { |
|
426 User::LeaveIfError( AknIconUtils::SetSize( |
|
427 digitSeparateMask, aRect.Size(), |
|
428 scalemode ) ); |
|
429 } |
|
430 |
|
431 CFbsBitmap* digitHardMask = digitSeparateMask; |
|
432 CFbsBitmap* digitSoftMask = digitDirectMask; |
|
433 if( separateMaskIsSoft ) |
|
434 { |
|
435 digitHardMask = digitDirectMask; |
|
436 digitSoftMask = digitSeparateMask; |
|
437 } |
|
438 |
|
439 // In case the mask sizes do not match (incorrect graphics), |
|
440 // select the smaller for rendering |
|
441 TSize digitRenderingSize = digitBitmap->SizeInPixels(); |
|
442 if( digitSeparateMask ) |
|
443 { |
|
444 TSize separateMaskSize = digitSeparateMask->SizeInPixels(); |
|
445 if( separateMaskSize.iWidth < digitRenderingSize.iWidth ) |
|
446 { |
|
447 digitRenderingSize.iWidth = separateMaskSize.iWidth; |
|
448 } |
|
449 if( separateMaskSize.iHeight < digitRenderingSize.iHeight ) |
|
450 { |
|
451 digitRenderingSize.iHeight = separateMaskSize.iHeight; |
|
452 } |
|
453 } |
|
454 |
|
455 if( aHardMask && digitBitmap && digitHardMask && |
|
456 // This check is needed because in some skins the |
|
457 // bitmap and hard mask might use the same display mode, |
|
458 // in which case the graphics become corrupted. |
|
459 digitHardMask->DisplayMode() < digitBitmap->DisplayMode() ) |
|
460 { |
|
461 aBufferGc.BitBltMasked( aRect.iTl, |
|
462 digitBitmap, |
|
463 TRect( TPoint(0,0), digitRenderingSize ), |
|
464 digitHardMask, |
|
465 EFalse ); |
|
466 } |
|
467 else if( !aHardMask && digitBitmap && digitSoftMask ) |
|
468 { |
|
469 aBufferGc.BitBltMasked( aRect.iTl, |
|
470 digitBitmap, |
|
471 TRect( TPoint(0,0), digitRenderingSize ), |
|
472 digitSoftMask, |
|
473 ETrue ); |
|
474 } |
|
475 } |
|
476 |
|
477 // ============================ MEMBER FUNCTIONS =============================== |
|
478 |
|
479 // ----------------------------------------------------------------------------- |
|
480 // CAknSkinnableClockFaceAnalogue::CAknSkinnableClockFaceAnalogue |
|
481 // C++ default constructor can NOT contain any code, that |
|
482 // might leave. |
|
483 // ----------------------------------------------------------------------------- |
|
484 // |
|
485 CAknSkinnableClockFaceAnalogue::CAknSkinnableClockFaceAnalogue( |
|
486 const TBool aShowDate ) : iShowDate( aShowDate ) |
|
487 { |
|
488 } |
|
489 |
|
490 // ----------------------------------------------------------------------------- |
|
491 // CAknSkinnableClockFaceAnalogue::ConstructL |
|
492 // Symbian 2nd phase constructor can leave. |
|
493 // ----------------------------------------------------------------------------- |
|
494 // |
|
495 void CAknSkinnableClockFaceAnalogue::ConstructL() |
|
496 { |
|
497 } |
|
498 |
|
499 // ----------------------------------------------------------------------------- |
|
500 // CAknSkinnableClockFaceAnalogue::NewL |
|
501 // Two-phased constructor. |
|
502 // ----------------------------------------------------------------------------- |
|
503 // |
|
504 CAknSkinnableClockFaceAnalogue* CAknSkinnableClockFaceAnalogue::NewL( |
|
505 const TBool aShowDate ) |
|
506 { |
|
507 CAknSkinnableClockFaceAnalogue* self = |
|
508 new( ELeave ) CAknSkinnableClockFaceAnalogue( aShowDate ); |
|
509 |
|
510 CleanupStack::PushL( self ); |
|
511 self->ConstructL(); |
|
512 CleanupStack::Pop( self ); |
|
513 |
|
514 return self; |
|
515 } |
|
516 |
|
517 // ----------------------------------------------------------------------------- |
|
518 // Destructor |
|
519 // ----------------------------------------------------------------------------- |
|
520 // |
|
521 CAknSkinnableClockFaceAnalogue::~CAknSkinnableClockFaceAnalogue() |
|
522 { |
|
523 } |
|
524 |
|
525 // ----------------------------------------------------------------------------- |
|
526 // CAknSkinnableClockFaceAnalogue::DrawTimeToBitmap |
|
527 // (other items were commented in a header). |
|
528 // ----------------------------------------------------------------------------- |
|
529 // |
|
530 void CAknSkinnableClockFaceAnalogue::DrawTimeToBitmapL( TRect& aRect, |
|
531 CBitmapContext& aBufferGc, |
|
532 TTime& aTime ) |
|
533 { |
|
534 |
|
535 |
|
536 TRect bufferRect(aRect); |
|
537 |
|
538 TBool idleLayoutActive( AknStatuspaneUtils::IdleLayoutActive() ); |
|
539 |
|
540 TAknLayoutText currentDate; |
|
541 if ( idleLayoutActive ) |
|
542 { |
|
543 currentDate.LayoutText( bufferRect, |
|
544 AknLayoutScalable_Apps::popup_clock_analogue_window_t1() ); |
|
545 } |
|
546 else |
|
547 { |
|
548 currentDate.LayoutText( bufferRect, |
|
549 AknLayoutScalable_Apps::popup_clock_analogue_window_cp10_t1(1) ); |
|
550 } |
|
551 |
|
552 TSize faceSize( bufferRect.Size() ); |
|
553 |
|
554 |
|
555 TDateTime dateTime( aTime.DateTime() ); |
|
556 |
|
557 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
558 |
|
559 // 1-2: Face number 1 |
|
560 |
|
561 CFbsBitmap* skinBmp = NULL; |
|
562 CFbsBitmap* softMaskBmp = NULL; |
|
563 |
|
564 AknsUtils::GetCachedMaskedBitmap( skin, |
|
565 KAknsIIDQsnCpClockAnalogueFace1, |
|
566 skinBmp, |
|
567 softMaskBmp ); |
|
568 if( !softMaskBmp ) |
|
569 { |
|
570 softMaskBmp = AknsUtils::GetCachedBitmap( skin, |
|
571 KAknsIIDQsnCpClockAnalogueFace1MaskSoft ); |
|
572 } |
|
573 |
|
574 // If there is no bitmap, don't draw |
|
575 if( !skinBmp ) |
|
576 { |
|
577 return; |
|
578 } |
|
579 |
|
580 User::LeaveIfError( AknIconUtils::SetSize( skinBmp, faceSize ) ); |
|
581 |
|
582 if( softMaskBmp ) |
|
583 { |
|
584 User::LeaveIfError( AknIconUtils::SetSize( softMaskBmp, faceSize) ); |
|
585 aBufferGc.BitBltMasked( bufferRect.iTl, |
|
586 skinBmp, |
|
587 TRect( TPoint(0,0), skinBmp->SizeInPixels() ), |
|
588 softMaskBmp, |
|
589 ETrue ); |
|
590 } |
|
591 else |
|
592 { |
|
593 aBufferGc.BitBlt( TPoint(0,0), skinBmp ); |
|
594 } |
|
595 |
|
596 aBufferGc.SetBrushStyle( CGraphicsContext::ENullBrush ); |
|
597 aBufferGc.SetPenStyle( CGraphicsContext::ESolidPen ); |
|
598 |
|
599 // 3: Date |
|
600 TBool skindateflag = EFalse; |
|
601 TRAPD( error, ( skindateflag = AknsUtils::BooleanPropertyL( |
|
602 skin, KAknsIIDPropertyAnalogueClockDate ) ) ); |
|
603 if (error) |
|
604 { |
|
605 skindateflag = ETrue; |
|
606 } |
|
607 |
|
608 if ( AknStatuspaneUtils::ExtendedLayoutActive() && |
|
609 idleLayoutActive && |
|
610 iShowDate ) |
|
611 { |
|
612 skindateflag = EFalse; // Date is not shown in extended sp idle clock |
|
613 } |
|
614 |
|
615 if( skindateflag && iShowDate ) |
|
616 { |
|
617 CAknsMaskedBitmapItemData* skinMaskedBmp = |
|
618 static_cast<CAknsMaskedBitmapItemData*>( |
|
619 skin->GetCachedItemData( KAknsIIDQsnCpClockAnalogueBorderNum, |
|
620 EAknsITMaskedBitmap ) ); |
|
621 |
|
622 if( skinMaskedBmp ) |
|
623 { |
|
624 User::LeaveIfError( AknIconUtils::SetSize( |
|
625 skinMaskedBmp->Bitmap(), faceSize) ); |
|
626 |
|
627 aBufferGc.BitBltMasked( |
|
628 bufferRect.iTl, |
|
629 skinMaskedBmp->Bitmap(), |
|
630 TRect( TPoint(0,0), skinMaskedBmp->Bitmap()->SizeInPixels() ), |
|
631 skinMaskedBmp->Mask(), |
|
632 EFalse ); |
|
633 } |
|
634 |
|
635 TBuf<2> dateText; |
|
636 dateText.Num( aTime.DayNoInMonth() + 1 ); |
|
637 TRgb dateColor = KRgbBlack; |
|
638 AknsUtils::GetCachedColor( skin, |
|
639 dateColor, |
|
640 KAknsIIDQsnIconColors, |
|
641 EAknsCIQsnIconColorsCG1 ); |
|
642 currentDate.DrawText( aBufferGc, dateText, ETrue, dateColor ); |
|
643 } |
|
644 |
|
645 // X: Hands |
|
646 |
|
647 DrawHands( aBufferGc, bufferRect, dateTime ); |
|
648 |
|
649 // 4-5: Face number 2 (glass) |
|
650 |
|
651 AknsUtils::GetCachedMaskedBitmap( |
|
652 skin, KAknsIIDQsnCpClockAnalogueFace2, |
|
653 skinBmp, softMaskBmp ); |
|
654 if( !softMaskBmp ) |
|
655 { |
|
656 softMaskBmp = AknsUtils::GetCachedBitmap( skin, |
|
657 KAknsIIDQsnCpClockAnalogueFace2MaskSoft ); |
|
658 } |
|
659 |
|
660 if( skinBmp && softMaskBmp ) |
|
661 { |
|
662 User::LeaveIfError( AknIconUtils::SetSize( skinBmp, faceSize ) ); |
|
663 User::LeaveIfError( AknIconUtils::SetSize( softMaskBmp, faceSize ) ); |
|
664 aBufferGc.BitBltMasked( bufferRect.iTl, |
|
665 skinBmp, |
|
666 TRect(TPoint(0,0), skinBmp->SizeInPixels() ), |
|
667 softMaskBmp, |
|
668 ETrue ); |
|
669 } |
|
670 } |
|
671 |
|
672 // ----------------------------------------------------------------------------- |
|
673 // CAknSkinnableClockFaceAnalogue::DrawHands |
|
674 // (other items were commented in a header). |
|
675 // ----------------------------------------------------------------------------- |
|
676 // |
|
677 void CAknSkinnableClockFaceAnalogue::DrawHands( CBitmapContext& aBufferGc, |
|
678 const TRect& aBufferRect, |
|
679 const TDateTime& aDateTime ) |
|
680 { |
|
681 TRect rect( aBufferRect ); |
|
682 |
|
683 TAknWindowLineLayout smallClockLayout( |
|
684 AknLayoutScalable_Apps::popup_clock_analogue_window() ); |
|
685 |
|
686 TAknWindowComponentLayout layout1( |
|
687 AknLayoutScalable_Apps::popup_clock_analogue_window_g3() ); |
|
688 TAknWindowComponentLayout layout2( |
|
689 AknLayoutScalable_Apps::popup_clock_analogue_window_g4() ); |
|
690 |
|
691 if ( !AknStatuspaneUtils::IdleLayoutActive() && |
|
692 rect.Width() > smallClockLayout.iW ) |
|
693 { |
|
694 layout1 = AknLayoutScalable_Apps::popup_clock_analogue_window_cp10_g3(1); |
|
695 layout2 = AknLayoutScalable_Apps::popup_clock_analogue_window_cp10_g4(1); |
|
696 } |
|
697 |
|
698 TAknLayoutRect hourPointerLayout; |
|
699 hourPointerLayout.LayoutRect( aBufferRect, |
|
700 layout1 ); |
|
701 TAknLayoutRect minutePointerLayout; |
|
702 minutePointerLayout.LayoutRect( aBufferRect, |
|
703 layout2 ); |
|
704 |
|
705 TAknLayoutRect scalableHourPointerLayout; |
|
706 TAknLayoutRect scalableMinutePointerLayout; |
|
707 |
|
708 if ( AknStatuspaneUtils::ExtendedLayoutActive() && |
|
709 AknStatuspaneUtils::IdleLayoutActive() && |
|
710 iShowDate) |
|
711 { |
|
712 // status pane clock in extended status pane |
|
713 scalableHourPointerLayout.LayoutRect( aBufferRect, |
|
714 AknLayoutScalable_Avkon::popup_clock_analogue_window_g3() ); |
|
715 |
|
716 scalableMinutePointerLayout.LayoutRect( aBufferRect, |
|
717 AknLayoutScalable_Avkon::popup_clock_analogue_window_g4() ); |
|
718 } |
|
719 else |
|
720 { |
|
721 // Main pane clock or landscape idle clock |
|
722 scalableHourPointerLayout.LayoutRect( aBufferRect, |
|
723 layout1 ); |
|
724 scalableMinutePointerLayout.LayoutRect( aBufferRect, |
|
725 layout2 ); |
|
726 } |
|
727 |
|
728 TRect scalableHourPointerRect( scalableHourPointerLayout.Rect() ); |
|
729 TRect scalableMinutePointerRect( scalableMinutePointerLayout.Rect() ); |
|
730 |
|
731 CFbsBitmap* hrbitmap = NULL; |
|
732 CFbsBitmap* hrmask = NULL; |
|
733 |
|
734 CFbsBitmap* minbitmap = NULL; |
|
735 CFbsBitmap* minmask = NULL; |
|
736 |
|
737 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
738 AknsUtils::GetCachedMaskedBitmap( |
|
739 skin, KAknsIIDQsnCpClockAnaloguePointerHour, |
|
740 hrbitmap, hrmask ); |
|
741 AknsUtils::GetCachedMaskedBitmap( |
|
742 skin, KAknsIIDQsnCpClockAnaloguePointerMinute, |
|
743 minbitmap, minmask ); |
|
744 |
|
745 TReal angle, length; |
|
746 TPoint handEndPoint; |
|
747 TReal sin, cos, temp; |
|
748 TInt mathErr( KErrNone ); |
|
749 |
|
750 TRect hourPointerRect( hourPointerLayout.Rect() ); |
|
751 TRect minutePointerRect( minutePointerLayout.Rect() ); |
|
752 |
|
753 TInt hour = aDateTime.Hour(); |
|
754 TInt minute = aDateTime.Minute(); |
|
755 |
|
756 if ( !hrbitmap || !hrmask ) |
|
757 { |
|
758 angle = TReal( hour * 60 + minute ) * |
|
759 KPi / 360.0 - KPiBy2; |
|
760 length = TReal( hourPointerRect.Height() ); |
|
761 mathErr = Math::Sin( sin, angle ); |
|
762 mathErr |= Math::Cos( cos, angle ); |
|
763 mathErr |= Math::Round( temp, cos * length, 0 ); |
|
764 handEndPoint.iX = TInt( temp ); |
|
765 mathErr |= Math::Round( temp, sin * length, 0 ); |
|
766 handEndPoint.iY = TInt( temp ); |
|
767 handEndPoint += hourPointerRect.iTl; |
|
768 |
|
769 if( !mathErr ) |
|
770 { |
|
771 aBufferGc.SetPenColor( hourPointerLayout.Color() ); |
|
772 aBufferGc.SetPenSize( TSize( hourPointerRect.Width(), |
|
773 hourPointerRect.Width() ) ); |
|
774 aBufferGc.DrawLine( hourPointerRect.iTl, handEndPoint ); |
|
775 } |
|
776 } |
|
777 else |
|
778 { |
|
779 // Ignore possible error. |
|
780 AknIconUtils::SetSizeAndRotation( |
|
781 hrbitmap, |
|
782 scalableHourPointerRect.Size(), |
|
783 EAspectRatioPreserved, |
|
784 hour * 30 + minute / 2 ); |
|
785 |
|
786 aBufferGc.BitBltMasked( scalableHourPointerRect.iTl, |
|
787 hrbitmap, |
|
788 TRect( TPoint(0,0), hrbitmap->SizeInPixels() ), |
|
789 hrmask, |
|
790 EFalse ); |
|
791 } |
|
792 |
|
793 if ( !minbitmap || !minmask ) |
|
794 { |
|
795 angle = TReal( minute * 6 ) * KPi / 180.0 - KPiBy2; |
|
796 length = TReal( minutePointerRect.Height() ); |
|
797 mathErr |= Math::Sin( sin, angle ); |
|
798 mathErr |= Math::Cos( cos, angle ); |
|
799 mathErr |= Math::Round( temp, cos * length, 0 ); |
|
800 handEndPoint.iX = TInt( temp ); |
|
801 mathErr |= Math::Round( temp, sin * length, 0 ); |
|
802 handEndPoint.iY = TInt( temp ); |
|
803 handEndPoint += minutePointerRect.iTl; |
|
804 |
|
805 if( !mathErr ) |
|
806 { |
|
807 aBufferGc.SetPenColor( minutePointerLayout.Color() ); |
|
808 aBufferGc.SetPenSize( TSize( minutePointerRect.Width(), |
|
809 minutePointerRect.Width() ) ); |
|
810 aBufferGc.DrawLine( minutePointerRect.iTl, handEndPoint ); |
|
811 } |
|
812 } |
|
813 else |
|
814 { |
|
815 // Ignore possible error. |
|
816 AknIconUtils::SetSizeAndRotation( |
|
817 minbitmap, |
|
818 scalableMinutePointerRect.Size(), |
|
819 EAspectRatioPreserved, |
|
820 minute * 6 ); |
|
821 |
|
822 aBufferGc.BitBltMasked( scalableMinutePointerRect.iTl, |
|
823 minbitmap, |
|
824 TRect( TPoint(0,0), minbitmap->SizeInPixels() ), |
|
825 minmask, |
|
826 EFalse ); |
|
827 } |
|
828 } |
|
829 |
|
830 // End of File |