|
1 /* |
|
2 * Copyright (c) 2008 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: This is the source file for the CClockMainContainer class. |
|
15 * |
|
16 */ |
|
17 |
|
18 // System includes |
|
19 #include <AknsBasicBackgroundControlContext.h> |
|
20 #include <AknsSkinInstance.h> |
|
21 #include <AknsUtils.h> |
|
22 #include <AknsDrawUtils.h> |
|
23 #include <AknSkinnableClock.h> |
|
24 #include <csxhelp/clk.hlp.hrh> |
|
25 #include <aknlayoutscalable_apps.cdl.h> |
|
26 #include <aknlayoutscalable_avkon.cdl.h> |
|
27 #include <layoutmetadata.cdl.h> |
|
28 #include <clock.rsg> |
|
29 #include <StringLoader.h> |
|
30 #include <aknlists.h> |
|
31 #include <gulicon.h> |
|
32 #include <AknIconArray.h> |
|
33 #include <AknsConstants.h> |
|
34 #include <AknDef.h> |
|
35 #include <clockapp.mbg> |
|
36 #include <avkon.mbg> |
|
37 #include <tz.h> |
|
38 #include <tzlocalizer.h> |
|
39 #include <tzlocalizationdatatypes.h> |
|
40 #include <vtzrules.h> |
|
41 #include <aknbutton.h> |
|
42 |
|
43 // User includes |
|
44 #include "clockmaincontainer.h" |
|
45 #include "clockmainview.h" |
|
46 #include "clockalarmarray.h" |
|
47 #include "clockserverclt.h" |
|
48 #include "clockmarqueelabel.h" |
|
49 #include "clkcommon.h" |
|
50 #include "clock.hrh" |
|
51 #include "clock.h" |
|
52 #include "clock_debug.h" |
|
53 #include "clockappui.h" |
|
54 |
|
55 // Constants |
|
56 const TInt KNumOfIcons( 3 ); |
|
57 const TInt KHour( 60 ); |
|
58 const TInt KZerothRule( 0 ); |
|
59 const TInt KOffsetStringLength( 64 ); |
|
60 const TInt KLocationNameLength( 100 ); |
|
61 const TInt KDayNames[] = |
|
62 { |
|
63 R_QTN_WEEK_LONG_MONDAY, |
|
64 R_QTN_WEEK_LONG_TUESDAY, |
|
65 R_QTN_WEEK_LONG_WEDNESDAY, |
|
66 R_QTN_WEEK_LONG_THURSDAY, |
|
67 R_QTN_WEEK_LONG_FRIDAY, |
|
68 R_QTN_WEEK_LONG_SATURDAY, |
|
69 R_QTN_WEEK_LONG_SUNDAY |
|
70 }; |
|
71 |
|
72 TInt const KSwitchDelay = 200*1000; |
|
73 |
|
74 // Literals |
|
75 _LIT( KIconFileName, "\\resource\\apps\\clockapp.mif" ); |
|
76 _LIT( KPlusGMT, " \x202A+" ); |
|
77 _LIT( KMinusGMT, " \x202A" ); |
|
78 _LIT( KPDF, " \x202C" ); |
|
79 _LIT( KZero, "0" ); |
|
80 _LIT( KSpace, " " ); |
|
81 |
|
82 // --------------------------------------------------------- |
|
83 // CClockMainContainer::NewL |
|
84 // rest of the details are commented in the header |
|
85 // --------------------------------------------------------- |
|
86 // |
|
87 CClockMainContainer* CClockMainContainer::NewL( CClockMainView* aView, const TRect& aRect, CClockAlarmArray* aAlarmArray ) |
|
88 { |
|
89 __PRINTS( "CClockMainContainer::NewL - Entry" ); |
|
90 |
|
91 CClockMainContainer* self = new ( ELeave ) CClockMainContainer; |
|
92 CleanupStack::PushL( self ); |
|
93 |
|
94 self->ConstructL( aView, aRect, aAlarmArray ); |
|
95 |
|
96 CleanupStack::Pop( self ); |
|
97 |
|
98 __PRINTS( "CClockMainContainer::NewL - Exit" ); |
|
99 |
|
100 return self; |
|
101 } |
|
102 |
|
103 // --------------------------------------------------------- |
|
104 // CClockMainContainer::~CClockMainContainer |
|
105 // rest of the details are commented in the header |
|
106 // --------------------------------------------------------- |
|
107 // |
|
108 CClockMainContainer::~CClockMainContainer() |
|
109 { |
|
110 __PRINTS( "CClockMainContainer::~CClockMainContainer - Entry" ); |
|
111 |
|
112 if( iBgContext ) |
|
113 { |
|
114 delete iBgContext; |
|
115 iBgContext = NULL; |
|
116 } |
|
117 if( iSkinnableClock ) |
|
118 { |
|
119 delete iSkinnableClock; |
|
120 iSkinnableClock = NULL; |
|
121 } |
|
122 if( iListBox ) |
|
123 { |
|
124 delete iListBox; |
|
125 iListBox = NULL; |
|
126 } |
|
127 if( iDateString ) |
|
128 { |
|
129 delete iDateString; |
|
130 iDateString = NULL; |
|
131 } |
|
132 if( iDstIndicator ) |
|
133 { |
|
134 delete iDstIndicator; |
|
135 iDstIndicator = NULL; |
|
136 } |
|
137 if( iDstIndicatorMask ) |
|
138 { |
|
139 delete iDstIndicatorMask; |
|
140 iDstIndicatorMask = NULL; |
|
141 } |
|
142 if( iDayNameString ) |
|
143 { |
|
144 delete iDayNameString; |
|
145 iDayNameString = NULL; |
|
146 } |
|
147 if( iLocationString ) |
|
148 { |
|
149 delete iLocationString; |
|
150 iLocationString = NULL; |
|
151 } |
|
152 if( iLocationLabel ) |
|
153 { |
|
154 delete iLocationLabel; |
|
155 iLocationLabel = NULL; |
|
156 } |
|
157 if( iTimeZoneString ) |
|
158 { |
|
159 delete iTimeZoneString; |
|
160 iTimeZoneString = NULL; |
|
161 } |
|
162 |
|
163 delete iNewAlarmButton; |
|
164 iNewAlarmButton = NULL; |
|
165 __PRINTS( "CClockMainContainer::~CClockMainContainer - Exit" ); |
|
166 } |
|
167 |
|
168 // --------------------------------------------------------- |
|
169 // CClockMainContainer::OfferKeyEventL |
|
170 // rest of the details are commented in the header |
|
171 // --------------------------------------------------------- |
|
172 // |
|
173 TKeyResponse CClockMainContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent, |
|
174 TEventCode aType ) |
|
175 { |
|
176 __PRINTS( "CClockMainContainer::OfferKeyEventL - Entry" ); |
|
177 |
|
178 TKeyResponse retVal( EKeyWasNotConsumed ); |
|
179 |
|
180 if( EEventKey == aType ) |
|
181 { |
|
182 if( EStdKeyNo == aKeyEvent.iScanCode ) |
|
183 { |
|
184 // This indicates that Call End key was pressed. |
|
185 // The timer is stopped and app is hidden in the background. |
|
186 iView->ClockApplicationUi()->HandleCommandL( EClockMainViewExit ); |
|
187 |
|
188 retVal = EKeyWasConsumed; |
|
189 |
|
190 __PRINTS( "CClockMainContainer::OfferKeyEventL - Exit" ); |
|
191 |
|
192 return retVal; |
|
193 } |
|
194 |
|
195 if( EKeyUpArrow == aKeyEvent.iCode || |
|
196 EKeyDownArrow == aKeyEvent.iCode ) |
|
197 { |
|
198 |
|
199 TInt itemCount = iListBox->Model()->ItemTextArray()->MdcaCount(); |
|
200 // if neither has focus just then select button to be focused |
|
201 if( !iNewAlarmButton->IsFocused() && !iListBox->IsFocused() ) |
|
202 { |
|
203 iListBox->View()->ItemDrawer()->SetFlags( CListItemDrawer::EDisableHighlight ); |
|
204 iNewAlarmButton->SetFocus( ETrue ); |
|
205 DrawDeferred(); |
|
206 retVal = EKeyWasConsumed; |
|
207 } |
|
208 // button not focused and no list items -> set focus to button |
|
209 else if( itemCount == 0 && !iNewAlarmButton->IsFocused() ) |
|
210 { |
|
211 iListBox->View()->ItemDrawer()->SetFlags( CListItemDrawer::EDisableHighlight ); |
|
212 iListBox->SetFocus( EFalse ); |
|
213 iNewAlarmButton->SetFocus( ETrue ); |
|
214 DrawDeferred(); |
|
215 retVal = EKeyWasConsumed; |
|
216 } |
|
217 // button focused and listbox has items |
|
218 else if( iNewAlarmButton->IsFocused() && itemCount > 0 ) |
|
219 { |
|
220 iListBox->View()->ItemDrawer()->ClearFlags( CListItemDrawer::EDisableHighlight ); |
|
221 |
|
222 //clear ESingleClickDisabledHighlight flag only when navigation key is used |
|
223 if(iClearSingleClickFlag) |
|
224 { |
|
225 iListBox->View()->ItemDrawer()->ClearFlags( CListItemDrawer::ESingleClickDisabledHighlight ); |
|
226 iClearSingleClickFlag = EFalse; |
|
227 } |
|
228 |
|
229 iNewAlarmButton->SetFocus( EFalse ); |
|
230 iListBox->SetFocus( ETrue ); |
|
231 if( EKeyDownArrow == aKeyEvent.iCode ) |
|
232 { |
|
233 iListBox->SetCurrentItemIndex( itemCount - 1 ); |
|
234 } |
|
235 else |
|
236 { |
|
237 iListBox->SetCurrentItemIndex( 0 ); |
|
238 } |
|
239 retVal = iListBox->OfferKeyEventL( aKeyEvent, aType ); |
|
240 } |
|
241 // listbox focused |
|
242 else if( iListBox->IsFocused() && itemCount > 0 ) |
|
243 { |
|
244 // first item when only one item in the list |
|
245 if( iListBox->CurrentItemIndex() == 0 && itemCount == 1 ) |
|
246 { |
|
247 iListBox->View()->ItemDrawer()->SetFlags( CListItemDrawer::EDisableHighlight ); |
|
248 iListBox->SetFocus( EFalse ); |
|
249 iNewAlarmButton->SetFocus( ETrue ); |
|
250 DrawDeferred(); |
|
251 retVal = EKeyWasConsumed; |
|
252 } |
|
253 // first item |
|
254 else if( iListBox->CurrentItemIndex() == 0 && EKeyUpArrow == aKeyEvent.iCode ) |
|
255 { |
|
256 iListBox->View()->ItemDrawer()->SetFlags( CListItemDrawer::EDisableHighlight ); |
|
257 iListBox->SetFocus( EFalse ); |
|
258 iNewAlarmButton->SetFocus( ETrue ); |
|
259 DrawDeferred(); |
|
260 retVal = EKeyWasConsumed; |
|
261 } |
|
262 //last item |
|
263 else if( iListBox->CurrentItemIndex() == ( itemCount - 1 ) |
|
264 && EKeyDownArrow == aKeyEvent.iCode ) |
|
265 { |
|
266 iListBox->View()->ItemDrawer()->SetFlags( CListItemDrawer::EDisableHighlight ); |
|
267 iListBox->SetFocus( EFalse); |
|
268 iNewAlarmButton->SetFocus( ETrue ); |
|
269 DrawDeferred(); |
|
270 retVal = EKeyWasConsumed; |
|
271 } |
|
272 // Send the event to the listbox to handle the event. |
|
273 else |
|
274 { |
|
275 iListBox->View()->ItemDrawer()->ClearFlags( CListItemDrawer::EDisableHighlight ); |
|
276 retVal = iListBox->OfferKeyEventL( aKeyEvent, aType ); |
|
277 } |
|
278 } |
|
279 } |
|
280 |
|
281 if( ( EKeyBackspace == aKeyEvent.iCode || EKeyDelete == aKeyEvent.iCode ) && |
|
282 ( KZeroAlarms < iListBox->Model()->ItemTextArray()->MdcaCount() ) ) |
|
283 { |
|
284 // Handle backspace command. Deletes the selected alarm. |
|
285 //Single click integration |
|
286 if ( iListBox->IsFocused() && iView->MenuBar()->ItemSpecificCommandsEnabled() ) |
|
287 { |
|
288 // if highlighted |
|
289 iView->HandleCommandL( EClockRemoveAlarm ); |
|
290 retVal = EKeyWasConsumed; |
|
291 } |
|
292 // otherwise do nothing and don't consume key |
|
293 |
|
294 } |
|
295 //Single click integration |
|
296 if ( aKeyEvent.iCode == EKeyOK || aKeyEvent.iCode == EKeyEnter ) |
|
297 { |
|
298 // Send the event to the listbox to handle the event |
|
299 // if listbox is focused |
|
300 if( iListBox->IsFocused() && iListBox->Model()->ItemTextArray()->MdcaCount() > 0 ) |
|
301 { |
|
302 iListBox->OfferKeyEventL( aKeyEvent, aType ); |
|
303 retVal = EKeyWasConsumed; |
|
304 } |
|
305 else |
|
306 { |
|
307 // default action for the enter is button press |
|
308 TKeyEvent keyEvent; |
|
309 keyEvent.iCode = EKeyOK; |
|
310 keyEvent.iScanCode = EStdKeyDevice3; |
|
311 keyEvent.iModifiers = 0; |
|
312 keyEvent.iRepeats = 0; |
|
313 iNewAlarmButton->OfferKeyEventL( keyEvent, EEventKeyDown ); |
|
314 iNewAlarmButton->OfferKeyEventL( keyEvent, EEventKey ); |
|
315 iNewAlarmButton->OfferKeyEventL( keyEvent, EEventKeyUp ); |
|
316 retVal = EKeyWasConsumed; |
|
317 |
|
318 } |
|
319 } |
|
320 |
|
321 } |
|
322 |
|
323 __PRINTS( "CClockMainContainer::OfferKeyEventL - Exit" ); |
|
324 |
|
325 return retVal; |
|
326 } |
|
327 |
|
328 // --------------------------------------------------------- |
|
329 // CClockMainContainer::Draw |
|
330 // rest of the details are commented in the header |
|
331 // --------------------------------------------------------- |
|
332 // |
|
333 void CClockMainContainer::Draw( const TRect& aRect ) const |
|
334 { |
|
335 __PRINTS( "CClockMainContainer::Draw - Entry" ); |
|
336 |
|
337 CWindowGc& windowGc = SystemGc(); |
|
338 windowGc.Clear( aRect ); |
|
339 |
|
340 if( iBgContext ) |
|
341 { |
|
342 MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance(); |
|
343 AknsDrawUtils::Background( skinInstance, iBgContext, this, windowGc, aRect ); |
|
344 } |
|
345 |
|
346 // Draw the date and day text. |
|
347 DrawMainViewText( windowGc ); |
|
348 |
|
349 // TODO: Change the LCT when the new LCT data is available. |
|
350 // Check if the DST is ON. If so, display the DST indicator icon. |
|
351 if( iDSTOn ) |
|
352 { |
|
353 TAknLayoutRect dstIndicatorRect; |
|
354 |
|
355 if( Layout_Meta_Data::IsLandscapeOrientation() ) |
|
356 { |
|
357 dstIndicatorRect.LayoutRect( Rect(), |
|
358 AknLayoutScalable_Apps::main_clock2_pane_g1( KVGALandscapeVariant ).LayoutLine() ); |
|
359 } |
|
360 else |
|
361 { |
|
362 dstIndicatorRect.LayoutRect( Rect(), |
|
363 AknLayoutScalable_Apps::main_clock2_pane_g1( KVGAPortraitVariant ).LayoutLine() ); |
|
364 } |
|
365 |
|
366 AknIconUtils::SetSize( iDstIndicator, dstIndicatorRect.Rect().Size() ); |
|
367 dstIndicatorRect.DrawImage( windowGc, iDstIndicator, iDstIndicatorMask ); |
|
368 } |
|
369 |
|
370 __PRINTS( "CClockMainContainer::Draw - Exit" ); |
|
371 } |
|
372 |
|
373 // --------------------------------------------------------- |
|
374 // CClockMainContainer::FocusChanged |
|
375 // rest of the details are commented in the header |
|
376 // --------------------------------------------------------- |
|
377 // |
|
378 void CClockMainContainer::FocusChanged( TDrawNow /*aDrawNow*/ ) |
|
379 { |
|
380 __PRINTS( "CClockMainContainer::FocusChanged - Entry" ); |
|
381 |
|
382 __PRINTS( "CClockMainContainer::FocusChanged - Exit" ); |
|
383 } |
|
384 |
|
385 // --------------------------------------------------------- |
|
386 // CClockMainContainer::HandlePointerEventL |
|
387 // rest of the details are commented in the header |
|
388 // --------------------------------------------------------- |
|
389 // |
|
390 void CClockMainContainer::HandlePointerEventL( const TPointerEvent& aPointerEvent ) |
|
391 { |
|
392 __PRINTS( "CClockMainContainer::HandlePointerEventL - Entry" ); |
|
393 |
|
394 // Check first wheather touch is supported or not. |
|
395 if( !AknLayoutUtils::PenEnabled() ) |
|
396 { |
|
397 __PRINTS( "CClockMainContainer::HandlePointerEventL - Exit" ); |
|
398 |
|
399 return; |
|
400 } |
|
401 |
|
402 // to highlight the item in alarm list after long tapping |
|
403 //( when new alarm button is focused) |
|
404 if( iListBox && iListBox->Rect().Contains( aPointerEvent.iPosition ) && |
|
405 aPointerEvent.iType == TPointerEvent::EButton1Down && |
|
406 !iListBox->IsFocused() && iListBox->IsVisible() ) |
|
407 { |
|
408 iNewAlarmButton->SetFocus(EFalse); |
|
409 iListBox->View()->ItemDrawer()->ClearFlags( CListItemDrawer::EDisableHighlight ); |
|
410 } |
|
411 |
|
412 // to get the vibes let's handle skinnable clock as a special case |
|
413 // no need to to delegate pointer events to it |
|
414 if( iSkinnableClock && iSkinnableClock->Rect().Contains( aPointerEvent.iPosition ) ) |
|
415 { |
|
416 if( aPointerEvent.iType == TPointerEvent::EButton1Down ) |
|
417 { |
|
418 TTime now; |
|
419 now.HomeTime(); |
|
420 TInt64 launchFreq = now.MicroSecondsFrom( iPreviousClockTypeSwitch ).Int64(); |
|
421 if( launchFreq > MAKE_TINT64( 0, KSwitchDelay ) ) |
|
422 { |
|
423 iView->GiveVibes(); |
|
424 iView->HandleCommandL( EClockSwitchClockType ); |
|
425 iPreviousClockTypeSwitch.HomeTime(); |
|
426 } |
|
427 } |
|
428 else |
|
429 { |
|
430 CCoeControl::HandlePointerEventL( aPointerEvent ); |
|
431 } |
|
432 } |
|
433 else |
|
434 { |
|
435 CCoeControl::HandlePointerEventL( aPointerEvent ); |
|
436 } |
|
437 __PRINTS( "CClockMainContainer::HandlePointerEventL - Exit" ); |
|
438 } |
|
439 |
|
440 // --------------------------------------------------------- |
|
441 // CClockMainContainer::HandleListBoxEventL |
|
442 // rest of the details are commented in the header |
|
443 // --------------------------------------------------------- |
|
444 // |
|
445 void CClockMainContainer::HandleListBoxEventL( CEikListBox* aListBox, TListBoxEvent aEventType ) |
|
446 { |
|
447 __PRINTS( "CClockMainContainer::HandleListBoxEventL - Entry" ); |
|
448 if( aListBox == iListBox && |
|
449 ( aEventType == EEventItemSingleClicked || aEventType == EEventEnterKeyPressed ) ) |
|
450 { |
|
451 // Check if the user has double clicked on the list item. |
|
452 if( !iView->IsAlarmEditorOpen() ) |
|
453 { |
|
454 iView->HandleCommandL( EClockResetAlarm ); |
|
455 } |
|
456 } |
|
457 |
|
458 __PRINTS( "CClockMainContainer::HandleListBoxEventL - Entry" ); |
|
459 } |
|
460 |
|
461 // --------------------------------------------------------- |
|
462 // CClockMainContainer::UpdateAlarmListL |
|
463 // rest of the details are commented in the header |
|
464 // --------------------------------------------------------- |
|
465 // |
|
466 void CClockMainContainer::UpdateAlarmListL( SClkAlarmInfo& /*aAlarmInfo*/, TAlarmId aAlarmId ) |
|
467 { |
|
468 __PRINTS( "CClockMainContainer::UpdateAlarmListL - Entry" ); |
|
469 |
|
470 // Reinitialize the alarm id array. |
|
471 iAlarmArray->InitIdList(); |
|
472 iListBox->HandleItemAdditionL(); |
|
473 |
|
474 // Get the index of the new alarm added. |
|
475 TInt itemIndex( iAlarmArray->ListBoxIndex( aAlarmId ) ); |
|
476 |
|
477 // Update the listbox. |
|
478 iListBox->ScrollToMakeItemVisible( itemIndex ); |
|
479 iListBox->SetCurrentItemIndexAndDraw( itemIndex ); |
|
480 SetCorrectRectForNewAlarmButton(); |
|
481 iNewAlarmButton->DrawDeferred(); |
|
482 iClearSingleClickFlag = ETrue; |
|
483 __PRINTS( "CClockMainContainer::UpdateAlarmListL - Exit" ); |
|
484 } |
|
485 |
|
486 // --------------------------------------------------------- |
|
487 // CClockMainContainer::RemoveAlarmL |
|
488 // rest of the details are commented in the header |
|
489 // --------------------------------------------------------- |
|
490 // |
|
491 void CClockMainContainer::RemoveAlarmL( TInt aIndex ) |
|
492 { |
|
493 __PRINTS( "CClockMainContainer::RemoveAlarmL - Entry" ); |
|
494 |
|
495 // Reinitialize the alarm list. |
|
496 iAlarmArray->InitIdList(); |
|
497 TInt count = iListBox->Model()->ItemTextArray()->MdcaCount(); |
|
498 |
|
499 // if only one item |
|
500 if( ( KZeroAlarms == aIndex ) && ( aIndex == count ) ) |
|
501 { |
|
502 iListBox->SetCurrentItemIndex( KZeroAlarms ); |
|
503 SetCorrectRectForNewAlarmButton(); |
|
504 } |
|
505 // last item when more than one exists |
|
506 else if( ( KZeroAlarms < aIndex ) && ( aIndex == count ) ) |
|
507 { |
|
508 // Last alarm in the list is deleted hence set the previous alarm. |
|
509 iListBox->ScrollToMakeItemVisible( aIndex - 1 ); |
|
510 iListBox->SetCurrentItemIndexAndDraw( aIndex - 1 ); |
|
511 iListBox->HandleItemRemovalL(); |
|
512 DrawNow(); |
|
513 } |
|
514 // not last item |
|
515 else if( ( KZeroAlarms <= aIndex ) && ( aIndex < count ) ) |
|
516 { |
|
517 // Highlight the alarm item replacing the deleted element |
|
518 iListBox->ScrollToMakeItemVisible( aIndex ); |
|
519 iListBox->SetCurrentItemIndexAndDraw( aIndex ); |
|
520 iListBox->HandleItemRemovalL(); |
|
521 DrawNow(); |
|
522 } |
|
523 |
|
524 __PRINTS( "CClockMainContainer::RemoveAlarmL - Exit" ); |
|
525 } |
|
526 |
|
527 // --------------------------------------------------------- |
|
528 // CClockMainContainer::ListBox |
|
529 // rest of the details are commented in the header |
|
530 // --------------------------------------------------------- |
|
531 // |
|
532 //Single click integration |
|
533 CAknDoubleStyleListBox* CClockMainContainer::ListBox() |
|
534 { |
|
535 __PRINTS( "CClockMainContainer::ListBox - Entry" ); |
|
536 |
|
537 __PRINTS( "CClockMainContainer::ListBox - Exit" ); |
|
538 |
|
539 return iListBox; |
|
540 } |
|
541 |
|
542 // --------------------------------------------------------- |
|
543 // CClockMainContainer::SetDayInfoL |
|
544 // rest of the details are commented in the header |
|
545 // --------------------------------------------------------- |
|
546 // |
|
547 void CClockMainContainer::SetDayInfoL() |
|
548 { |
|
549 __PRINTS( "CClockMainContainer::SetDayInfoL - Entry" ); |
|
550 |
|
551 // First get the current time. |
|
552 TTime homeTime; |
|
553 homeTime.HomeTime(); |
|
554 |
|
555 TDateString dateBuffer; |
|
556 |
|
557 // Construct the date string. |
|
558 HBufC* formatString = StringLoader::LoadLC( R_QTN_DATE_USUAL_WITH_ZERO, iCoeEnv ); |
|
559 // Format the time to get the date. |
|
560 homeTime.FormatL( dateBuffer, *formatString ); |
|
561 // Cleanup. |
|
562 CleanupStack::PopAndDestroy( formatString ); |
|
563 |
|
564 // Get the date string. |
|
565 if( iDateString ) |
|
566 { |
|
567 delete iDateString; |
|
568 iDateString = NULL; |
|
569 } |
|
570 iDateString = HBufC::NewL( dateBuffer.Length() ); |
|
571 TPtr dateStringPtr = iDateString->Des(); |
|
572 dateStringPtr.Append( dateBuffer ); |
|
573 |
|
574 // Get the day name string. |
|
575 if( iDayNameString ) |
|
576 { |
|
577 delete iDayNameString; |
|
578 iDayNameString = NULL; |
|
579 } |
|
580 iDayNameString = StringLoader::LoadL( KDayNames[ homeTime.DayNoInWeek() ], iCoeEnv ); |
|
581 |
|
582 __PRINTS( "CClockMainContainer::SetDayInfoL - Exit" ); |
|
583 } |
|
584 |
|
585 // --------------------------------------------------------- |
|
586 // CClockMainContainer::UpdateDSTStateL |
|
587 // rest of the details are commented in the header |
|
588 // --------------------------------------------------------- |
|
589 // |
|
590 void CClockMainContainer::UpdateDSTStateL() |
|
591 { |
|
592 __PRINTS( "CClockMainContainer::UpdateDSTStateL - Entry" ); |
|
593 |
|
594 RTz tzHandle; |
|
595 User::LeaveIfError( tzHandle.Connect() ); |
|
596 CleanupClosePushL( tzHandle ); |
|
597 |
|
598 CTzId* timezoneId = tzHandle.GetTimeZoneIdL(); |
|
599 CleanupStack::PushL( timezoneId ); |
|
600 |
|
601 if( tzHandle.IsDaylightSavingOnL( *timezoneId ) ) |
|
602 { |
|
603 iDSTOn = ETrue; |
|
604 } |
|
605 else |
|
606 { |
|
607 iDSTOn = EFalse; |
|
608 } |
|
609 |
|
610 CleanupStack::PopAndDestroy( timezoneId ); |
|
611 CleanupStack::PopAndDestroy( &tzHandle ); |
|
612 |
|
613 __PRINTS( "CClockMainContainer::UpdateDSTStateL - Exit" ); |
|
614 } |
|
615 |
|
616 // --------------------------------------------------------- |
|
617 // CClockMainContainer::SetZoneInfoL |
|
618 // rest of the details are commented in the header |
|
619 // --------------------------------------------------------- |
|
620 // |
|
621 void CClockMainContainer::SetZoneInfoL() |
|
622 { |
|
623 __PRINTS( "CClockMainContainer::SetZoneInfoL - Entry" ); |
|
624 |
|
625 TBuf< KOffsetStringLength > offsetString; |
|
626 TBuf< KLocationNameLength > locationName; |
|
627 TInt gmtOffset( KErrNone ); |
|
628 |
|
629 RArray< TInt > timeZones; |
|
630 RArray< TInt > timeZoneOffsets; |
|
631 |
|
632 // Connect to the timezone server. |
|
633 RTz tzHandle; |
|
634 User::LeaveIfError( tzHandle.Connect() ); |
|
635 CleanupClosePushL( tzHandle ); |
|
636 |
|
637 // Get the current timezone ID. |
|
638 CTzId* timeZoneId; |
|
639 timeZoneId = tzHandle.GetTimeZoneIdL(); |
|
640 CleanupStack::PushL( timeZoneId ); |
|
641 |
|
642 // Get all the timezone offsets corresponding to the current timezone ID. |
|
643 timeZones.Append( timeZoneId->TimeZoneNumericID() ); |
|
644 tzHandle.GetOffsetsForTimeZoneIdsL( timeZones, timeZoneOffsets ); |
|
645 |
|
646 // The offset of the current zone. |
|
647 TInt currentOffset( timeZoneOffsets[ KErrNone ] ); |
|
648 gmtOffset = currentOffset; |
|
649 |
|
650 // Check if the DST is on for the current timezone. |
|
651 if( IsDstOnL( timeZones[ 0 ] ) ) |
|
652 { |
|
653 TInt32 dstOffset; |
|
654 |
|
655 // Get the offset |
|
656 GetOffSetWithDstL( dstOffset, *timeZoneId ); |
|
657 |
|
658 // Update the gmt offset with DST offset. |
|
659 gmtOffset = dstOffset; |
|
660 } |
|
661 |
|
662 // Cleanup. |
|
663 timeZones.Close(); |
|
664 timeZoneOffsets.Close(); |
|
665 |
|
666 // Get all the localized timezones for the current timezone ID. |
|
667 CTzLocalizedTimeZone* localizedTimeZone( NULL ); |
|
668 CTzLocalizer* tzLocalizer( NULL ); |
|
669 TRAPD( errVal, tzLocalizer = CTzLocalizer::NewL() ); |
|
670 if( tzLocalizer && ( !errVal ) ) |
|
671 { |
|
672 // Get the currently set localized timezone. |
|
673 CleanupStack::PushL( tzLocalizer ); |
|
674 TRAPD( errVal, localizedTimeZone = tzLocalizer->GetLocalizedTimeZoneL( timeZoneId->TimeZoneNumericID() ) ); |
|
675 |
|
676 if( ( localizedTimeZone ) && ( !errVal ) ) |
|
677 { |
|
678 CleanupStack::PushL( localizedTimeZone ); |
|
679 |
|
680 // Get the frequently used localized city. |
|
681 CTzLocalizedCity* localizedCity = tzLocalizer->GetFrequentlyUsedZoneCityL( CTzLocalizedTimeZone::ECurrentZone ); |
|
682 CleanupStack::PushL( localizedCity ); |
|
683 |
|
684 // Get all the city groups. |
|
685 CTzLocalizedCityGroupArray* cityGroupArray = tzLocalizer->GetAllCityGroupsL( CTzLocalizer::ETzAlphaNameAscending ); |
|
686 CleanupStack::PushL( cityGroupArray ); |
|
687 |
|
688 // Get the index of the country corresponding to the city group ID. |
|
689 TInt countryIndex( 1 ); |
|
690 |
|
691 for( TInt index( KErrNone ); index < cityGroupArray->Count(); index++ ) |
|
692 { |
|
693 if( localizedCity->GroupId() == cityGroupArray->At( index ).Id() ) |
|
694 { |
|
695 countryIndex = index; |
|
696 } |
|
697 } |
|
698 |
|
699 // Get all the cities within the currently set country. |
|
700 CTzLocalizedCityArray* cityList = tzLocalizer->GetCitiesInGroupL( ( cityGroupArray->At( countryIndex ) ).Id(), |
|
701 CTzLocalizer::ETzAlphaNameAscending ); |
|
702 CleanupStack::PushL( cityList ); |
|
703 |
|
704 // Check if automatic time update is enabled. |
|
705 TBool timeUpdateOn( EFalse ); |
|
706 RClkSrvInterface clkSrvIf; |
|
707 |
|
708 // Connect to clockserver |
|
709 TInt errorVal( clkSrvIf.Connect() ); |
|
710 |
|
711 if( KErrNone == errorVal ) |
|
712 { |
|
713 // First check if automatic time update is enabled. |
|
714 errorVal = clkSrvIf.IsAutoTimeUpdateOn( timeUpdateOn ); |
|
715 } |
|
716 |
|
717 // Check if the country contains only one city or if automatic time update is on. |
|
718 if( 1 == cityList->Count() || timeUpdateOn ) |
|
719 { |
|
720 // If yes, then display only the country name. |
|
721 locationName.Copy( cityGroupArray->At( countryIndex ).Name() ); |
|
722 } |
|
723 else |
|
724 { |
|
725 // Automatic time update is disabled. Display the city name. |
|
726 locationName.Copy( localizedCity->Name() ); |
|
727 } |
|
728 |
|
729 // Close the handle to the clockserver. |
|
730 clkSrvIf.Close(); |
|
731 |
|
732 // Cleanup. |
|
733 CleanupStack::PopAndDestroy( cityList ); |
|
734 CleanupStack::PopAndDestroy( cityGroupArray ); |
|
735 CleanupStack::PopAndDestroy( localizedCity ); |
|
736 CleanupStack::PopAndDestroy( localizedTimeZone ); |
|
737 } |
|
738 // Cleanup. |
|
739 CleanupStack::PopAndDestroy( tzLocalizer ); |
|
740 } |
|
741 |
|
742 // Cleanup. |
|
743 CleanupStack::PopAndDestroy( timeZoneId ); |
|
744 CleanupStack::PopAndDestroy( &tzHandle ); |
|
745 |
|
746 // Now construct the GMT +/-X string. |
|
747 TInt tempOffset( gmtOffset ); |
|
748 TInt offsetHours( tempOffset / KHour ); |
|
749 TInt offsetMinutes( KErrNone ); |
|
750 TGmtOffsetText offsetText; |
|
751 |
|
752 if( KErrNone < tempOffset ) |
|
753 { |
|
754 // We have a positive offset. Append the + character. |
|
755 offsetMinutes = gmtOffset - offsetHours * KHour; |
|
756 offsetString += KPlusGMT; |
|
757 } |
|
758 else if( KErrNone > tempOffset ) |
|
759 { |
|
760 // Negative offset. Append the - character. |
|
761 offsetMinutes = -( gmtOffset - offsetHours * KHour ); |
|
762 offsetString += KMinusGMT; |
|
763 } |
|
764 else |
|
765 { |
|
766 // We dont have an offset. We are at GMT zone. |
|
767 offsetString += KSingleSpace; |
|
768 } |
|
769 // Append the hour component. |
|
770 offsetText.Num( offsetHours ); |
|
771 offsetString += offsetText; |
|
772 |
|
773 // Append the time separator. |
|
774 const TInt KSeparIndex( 1 ); |
|
775 offsetString.Append( TLocale().TimeSeparator( KSeparIndex ) ); |
|
776 |
|
777 // If the minute component is less than 10, append a '0' |
|
778 if ( KErrNone <= offsetMinutes && offsetMinutes < 10 ) |
|
779 { |
|
780 offsetString += KZero; |
|
781 } |
|
782 // Append the minute component. |
|
783 offsetText.Num( offsetMinutes ); |
|
784 offsetString += offsetText; |
|
785 offsetString += KPDF; |
|
786 |
|
787 // These will hold the complete zone information displayed on the main view. |
|
788 if( iLocationString ) |
|
789 { |
|
790 delete iLocationString; |
|
791 iLocationString = NULL; |
|
792 } |
|
793 if( iTimeZoneString ) |
|
794 { |
|
795 delete iTimeZoneString; |
|
796 iTimeZoneString = NULL; |
|
797 } |
|
798 |
|
799 // The GMT prefix which is prepended before the offset and zone information. |
|
800 HBufC* gmtPrefixText = StringLoader::LoadLC( R_QTN_CLK_NITZ_GMT, iCoeEnv ); |
|
801 |
|
802 // Construct the strings to the displayed. |
|
803 iTimeZoneString = HBufC::NewL( gmtPrefixText->Length() + offsetString.Length() ); |
|
804 iLocationString = HBufC::NewL( locationName.Length() ); |
|
805 // First the timezone string. |
|
806 TPtr timeZonePtr = iTimeZoneString->Des(); |
|
807 timeZonePtr += *gmtPrefixText; |
|
808 timeZonePtr += offsetString; |
|
809 |
|
810 // Then the location name. |
|
811 TPtr zoneInfoPtr = iLocationString->Des(); |
|
812 if( locationName.Length() ) |
|
813 { |
|
814 zoneInfoPtr += locationName; |
|
815 } |
|
816 |
|
817 // Cleanup. |
|
818 CleanupStack::PopAndDestroy( gmtPrefixText ); |
|
819 |
|
820 __PRINTS( "CClockMainContainer::SetZoneInfoL - Exit" ); |
|
821 } |
|
822 |
|
823 // --------------------------------------------------------- |
|
824 // CClockMainContainer::ResetMarqueeLabelL |
|
825 // rest of the details are commented in the header |
|
826 // --------------------------------------------------------- |
|
827 // |
|
828 void CClockMainContainer::ResetMarqueeLabelL() |
|
829 { |
|
830 __PRINTS( "CClockMainContainer::ResetMarqueeLabelL - Entry" ); |
|
831 |
|
832 // Reset the label so that it marquees again. |
|
833 if( iLocationLabel ) |
|
834 { |
|
835 iLocationLabel->ResetMarquee(); |
|
836 } |
|
837 |
|
838 __PRINTS( "CClockMainContainer::ResetMarqueeLabelL - Exit" ); |
|
839 } |
|
840 |
|
841 // --------------------------------------------------------- |
|
842 // CClockMainContainer::SizeChanged |
|
843 // rest of the details are commented in the header |
|
844 // --------------------------------------------------------- |
|
845 // |
|
846 void CClockMainContainer::SizeChanged() |
|
847 { |
|
848 __PRINTS( "CClockMainContainer::SizeChanged - Entry" ); |
|
849 |
|
850 TRect paneRect = this->Rect(); |
|
851 // Update the background context. |
|
852 iBgContext->SetRect( paneRect ); |
|
853 |
|
854 // The clock main rect. |
|
855 TAknLayoutRect mainRect; |
|
856 // The rect for the skinnable clock. |
|
857 TAknLayoutRect skinClockRect; |
|
858 // The rect for the listbox. |
|
859 TAknLayoutRect listBoxRect; |
|
860 |
|
861 // Get the layout for the main rect. |
|
862 mainRect.LayoutRect( paneRect, AknLayoutScalable_Apps::main_clock2_pane().LayoutLine() ); |
|
863 |
|
864 if( Layout_Meta_Data::IsLandscapeOrientation() ) |
|
865 { |
|
866 listBoxRect.LayoutRect( mainRect.Rect(), AknLayoutScalable_Apps::listscroll_gen_pane_cp06( 1 ).LayoutLine() ); |
|
867 skinClockRect.LayoutRect( mainRect.Rect(), |
|
868 AknLayoutScalable_Apps::popup_clock_analogue_window_cp03( KVGALandscapeVariant ).LayoutLine() ); |
|
869 } |
|
870 else |
|
871 { |
|
872 listBoxRect.LayoutRect( mainRect.Rect(), AknLayoutScalable_Apps::listscroll_gen_pane_cp06( 0 ).LayoutLine() ); |
|
873 skinClockRect.LayoutRect( mainRect.Rect(), |
|
874 AknLayoutScalable_Apps::popup_clock_analogue_window_cp03( KVGAPortraitVariant ).LayoutLine() ); |
|
875 } |
|
876 |
|
877 SetCorrectRectForNewAlarmButton(); |
|
878 |
|
879 // Update the skinnable clock. |
|
880 iSkinnableClock->SetExtent( skinClockRect.Rect().iTl, skinClockRect.Rect().Size() ); |
|
881 iSkinnableClock->UpdateDisplay(); |
|
882 |
|
883 // Update the listbox. |
|
884 iListBox->SetExtent( listBoxRect.Rect().iTl, listBoxRect.Rect().Size() ); |
|
885 |
|
886 __PRINTS( "CClockMainContainer::SizeChanged - Exit" ); |
|
887 } |
|
888 |
|
889 // --------------------------------------------------------- |
|
890 // CClockMainContainer::CountComponentControls |
|
891 // rest of the details are commented in the header |
|
892 // --------------------------------------------------------- |
|
893 // |
|
894 TInt CClockMainContainer::CountComponentControls() const |
|
895 { |
|
896 __PRINTS( "CClockMainContainer::CountComponentControls - Entry" ); |
|
897 |
|
898 __PRINTS( "CClockMainContainer::CountComponentControls - Exit" ); |
|
899 |
|
900 return 3; |
|
901 } |
|
902 |
|
903 // --------------------------------------------------------- |
|
904 // CClockMainContainer::ComponentControl |
|
905 // rest of the details are commented in the header |
|
906 // --------------------------------------------------------- |
|
907 // |
|
908 CCoeControl* CClockMainContainer::ComponentControl( TInt aIndex ) const |
|
909 { |
|
910 __PRINTS( "CClockMainContainer::ComponentControl - Entry" ); |
|
911 |
|
912 switch( aIndex ) |
|
913 { |
|
914 case 0: |
|
915 { |
|
916 __PRINTS( "CClockMainContainer::ComponentControl - Exit" ); |
|
917 |
|
918 // Return the skinnable clock. |
|
919 return iSkinnableClock; |
|
920 } |
|
921 |
|
922 case 1: |
|
923 { |
|
924 __PRINTS( "CClockMainContainer::ComponentControl - Exit" ); |
|
925 |
|
926 // Return the new alarm button. |
|
927 return iNewAlarmButton; |
|
928 } |
|
929 |
|
930 case 2: |
|
931 { |
|
932 __PRINTS( "CClockMainContainer::ComponentControl - Exit" ); |
|
933 |
|
934 // Return the listbox. |
|
935 return iListBox; |
|
936 } |
|
937 |
|
938 default: |
|
939 { |
|
940 __PRINTS( "CClockMainContainer::ComponentControl - Exit" ); |
|
941 |
|
942 return NULL; |
|
943 } |
|
944 } |
|
945 } |
|
946 |
|
947 // --------------------------------------------------------- |
|
948 // CClockMainContainer::MopSupplyObject |
|
949 // rest of the details are commented in the header |
|
950 // --------------------------------------------------------- |
|
951 // |
|
952 TTypeUid::Ptr CClockMainContainer::MopSupplyObject( TTypeUid aId ) |
|
953 { |
|
954 __PRINTS( "CClockMainContainer::MopSupplyObject - Entry" ); |
|
955 |
|
956 if( MAknsControlContext::ETypeId == aId.iUid ) |
|
957 { |
|
958 __PRINTS( "CClockMainContainer::MopSupplyObject - Exit" ); |
|
959 |
|
960 return MAknsControlContext::SupplyMopObject( aId, iBgContext ); |
|
961 } |
|
962 |
|
963 __PRINTS( "CClockMainContainer::MopSupplyObject - Exit" ); |
|
964 |
|
965 return CCoeControl::MopSupplyObject( aId ); |
|
966 } |
|
967 |
|
968 // --------------------------------------------------------- |
|
969 // CClockMainContainer::HandleResourceChange |
|
970 // rest of the details are commented in the header |
|
971 // --------------------------------------------------------- |
|
972 // |
|
973 void CClockMainContainer::HandleResourceChange( TInt aType ) |
|
974 { |
|
975 __PRINTS( "CClockMainContainer::HandleResourceChange - Entry" ); |
|
976 |
|
977 // If skinnable clock is present, let it handle the resource change. |
|
978 if( iSkinnableClock ) |
|
979 { |
|
980 iSkinnableClock->HandleResourceChange( aType ); |
|
981 } |
|
982 |
|
983 // Allow the listbox to handle the resource change. |
|
984 if( iNewAlarmButton ) |
|
985 { |
|
986 iNewAlarmButton->HandleResourceChange( aType ); |
|
987 } |
|
988 |
|
989 // Allow the listbox to handle the resource change. |
|
990 if( iListBox ) |
|
991 { |
|
992 iListBox->HandleResourceChange( aType ); |
|
993 } |
|
994 // Then let the controlenvironment handle the change. |
|
995 CCoeControl::HandleResourceChange( aType ); |
|
996 |
|
997 switch( aType ) |
|
998 { |
|
999 case KEikMessageWindowsFadeChange: |
|
1000 case KEikDynamicLayoutVariantSwitch: |
|
1001 { |
|
1002 SetRect( iView->ClientRect() ); |
|
1003 // Destroy and reconstruct the label again so that it marquees whenever the orientation changes. |
|
1004 ResetMarqueeLabelL(); |
|
1005 |
|
1006 |
|
1007 } |
|
1008 break; |
|
1009 |
|
1010 case KAknsMessageSkinChange: |
|
1011 { |
|
1012 // First get the icon array from listbox item drawer. |
|
1013 CArrayPtr< CGulIcon >* iconArray = iListBox->ItemDrawer()->FormattedCellData()->IconArray(); |
|
1014 |
|
1015 if( iconArray ) |
|
1016 { |
|
1017 // Reset the iconArray. |
|
1018 iconArray->ResetAndDestroy(); |
|
1019 delete iconArray; |
|
1020 iconArray = NULL; |
|
1021 iListBox->ItemDrawer()->FormattedCellData()->SetIconArray( NULL ); |
|
1022 } |
|
1023 |
|
1024 // Reload the icons into the array. |
|
1025 iconArray = new( ELeave ) CAknIconArray( KNumOfIcons ); |
|
1026 CleanupStack::PushL( iconArray ); |
|
1027 |
|
1028 CFbsBitmap* iconBitmap( NULL ); |
|
1029 CFbsBitmap* iconMask( NULL ); |
|
1030 CGulIcon* finalIcon( NULL ); |
|
1031 |
|
1032 // First read the alarm icon. |
|
1033 AknsUtils::CreateColorIconL( AknsUtils::SkinInstance(), |
|
1034 KAknsIIDQgnIndiAlarmAdd, |
|
1035 KAknsIIDQsnIconColors, |
|
1036 EAknsCIQsnIconColorsCG13, |
|
1037 iconBitmap, |
|
1038 iconMask, |
|
1039 AknIconUtils::AvkonIconFileName(), |
|
1040 EMbmAvkonQgn_indi_alarm_add, |
|
1041 EMbmAvkonQgn_indi_alarm_add_mask, |
|
1042 TRgb( NULL, NULL, 255 ) ); |
|
1043 CleanupStack::PushL( iconBitmap ); |
|
1044 CleanupStack::PushL( iconMask ); |
|
1045 // Construct the icon. |
|
1046 finalIcon = CGulIcon::NewL( iconBitmap, iconMask ); |
|
1047 CleanupStack::PushL( finalIcon ); |
|
1048 // Append the above icon to the array. |
|
1049 iconArray->AppendL( finalIcon ); |
|
1050 // Cleanup. |
|
1051 CleanupStack::Pop( finalIcon ); |
|
1052 CleanupStack::Pop( iconMask ); |
|
1053 CleanupStack::Pop( iconBitmap ); |
|
1054 |
|
1055 // Now load the repeat icon. |
|
1056 iconBitmap = NULL; |
|
1057 iconMask = NULL; |
|
1058 |
|
1059 AknsUtils::CreateColorIconL( AknsUtils::SkinInstance(), |
|
1060 KAknsIIDQgnIndiRepeatAdd, |
|
1061 KAknsIIDQsnIconColors, |
|
1062 EAknsCIQsnIconColorsCG13, |
|
1063 iconBitmap, |
|
1064 iconMask, |
|
1065 KIconFileName, |
|
1066 EMbmClockappQgn_indi_repeat_add, |
|
1067 EMbmClockappQgn_indi_repeat_add_mask, |
|
1068 TRgb( NULL, NULL, 255 ) ); |
|
1069 CleanupStack::PushL( iconBitmap ); |
|
1070 CleanupStack::PushL( iconMask ); |
|
1071 // Construct the icon. |
|
1072 finalIcon = NULL; |
|
1073 finalIcon = CGulIcon::NewL( iconBitmap, iconMask ); |
|
1074 CleanupStack::PushL( finalIcon ); |
|
1075 // Append the above icon to the array. |
|
1076 iconArray->AppendL( finalIcon ); |
|
1077 // Cleanup. |
|
1078 CleanupStack::Pop( finalIcon ); |
|
1079 CleanupStack::Pop( iconMask ); |
|
1080 CleanupStack::Pop( iconBitmap ); |
|
1081 |
|
1082 // Read the inactive icon. |
|
1083 iconBitmap = NULL; |
|
1084 iconMask = NULL; |
|
1085 |
|
1086 // Create the color icon for the alarm inactive icon. |
|
1087 AknsUtils::CreateColorIconL( AknsUtils::SkinInstance(), |
|
1088 KAknsIIDQgnIndiAlarmInactiveAdd, |
|
1089 KAknsIIDQsnIconColors, |
|
1090 EAknsCIQsnIconColorsCG13, |
|
1091 iconBitmap, |
|
1092 iconMask, |
|
1093 KIconFileName, |
|
1094 EMbmClockappQgn_indi_alarm_inactive_add, |
|
1095 EMbmClockappQgn_indi_alarm_inactive_add_mask, |
|
1096 TRgb( NULL, NULL, 255 ) ); |
|
1097 CleanupStack::PushL( iconBitmap ); |
|
1098 CleanupStack::PushL( iconMask ); |
|
1099 |
|
1100 // Construct the icon. |
|
1101 finalIcon = CGulIcon::NewL( iconBitmap, iconMask ); |
|
1102 CleanupStack::PushL( finalIcon ); |
|
1103 // Append the above icon to the array. |
|
1104 iconArray->AppendL( finalIcon ); |
|
1105 // Cleanup. |
|
1106 CleanupStack::Pop( finalIcon ); |
|
1107 CleanupStack::Pop( iconMask ); |
|
1108 CleanupStack::Pop( iconBitmap ); |
|
1109 |
|
1110 // Now load a blank icon. |
|
1111 iconBitmap = new( ELeave ) CFbsBitmap(); |
|
1112 CleanupStack::PushL( iconBitmap ); |
|
1113 iconMask = new( ELeave ) CFbsBitmap(); |
|
1114 CleanupStack::PushL( iconMask ); |
|
1115 |
|
1116 iconBitmap->Create( TSize( NULL, NULL ), ENone ); |
|
1117 iconMask->Create( TSize( NULL, NULL ), ENone ); |
|
1118 |
|
1119 // Construct the icon. |
|
1120 finalIcon = NULL; |
|
1121 finalIcon = CGulIcon::NewL( iconBitmap, iconMask ); |
|
1122 CleanupStack::PushL( finalIcon ); |
|
1123 // Append it to the icon array. |
|
1124 iconArray->AppendL( finalIcon ); |
|
1125 // Cleanup. |
|
1126 CleanupStack::Pop( finalIcon ); |
|
1127 CleanupStack::Pop( iconMask ); |
|
1128 CleanupStack::Pop( iconBitmap ); |
|
1129 |
|
1130 // Set the iconarray to the itemdrawer of the listbox. |
|
1131 iListBox->ItemDrawer()->FormattedCellData()->SetIconArray( iconArray ); |
|
1132 CleanupStack::Pop( iconArray ); |
|
1133 iconArray = NULL; |
|
1134 |
|
1135 // Delete the DST icon and refresh it again. |
|
1136 if( iDstIndicator ) |
|
1137 { |
|
1138 delete iDstIndicator; |
|
1139 iDstIndicator = NULL; |
|
1140 } |
|
1141 if( iDstIndicatorMask ) |
|
1142 { |
|
1143 delete iDstIndicatorMask; |
|
1144 iDstIndicatorMask = NULL; |
|
1145 } |
|
1146 AknsUtils::CreateColorIconL( AknsUtils::SkinInstance(), |
|
1147 KAknsIIDQgnIndiDstAdd, |
|
1148 KAknsIIDQsnIconColors, |
|
1149 EAknsCIQsnIconColorsCG13, |
|
1150 iDstIndicator, |
|
1151 iDstIndicatorMask, |
|
1152 AknIconUtils::AvkonIconFileName(), |
|
1153 EMbmAvkonQgn_indi_dst_add, |
|
1154 EMbmAvkonQgn_indi_dst_add_mask, |
|
1155 TRgb( NULL, NULL, 255 ) ); |
|
1156 } |
|
1157 } |
|
1158 |
|
1159 __PRINTS( "CClockMainContainer::HandleResourceChange - Exit" ); |
|
1160 } |
|
1161 |
|
1162 // --------------------------------------------------------- |
|
1163 // CClockMainContainer::ConstructL |
|
1164 // rest of the details are commented in the header |
|
1165 // --------------------------------------------------------- |
|
1166 // |
|
1167 void CClockMainContainer::ConstructL( CClockMainView* aView, const TRect& aRect, CClockAlarmArray* aAlarmArray ) |
|
1168 { |
|
1169 __PRINTS( "CClockMainContainer::ConstructL - Entry" ); |
|
1170 |
|
1171 iView = aView; |
|
1172 iAlarmArray = aAlarmArray; |
|
1173 iClearSingleClickFlag = ETrue; |
|
1174 CreateWindowL(); |
|
1175 |
|
1176 // Construct the basic skin context. |
|
1177 iBgContext = CAknsBasicBackgroundControlContext::NewL( KAknsIIDQsnBgAreaMain, |
|
1178 aRect, |
|
1179 EFalse ); |
|
1180 |
|
1181 // Here we load the two icons for alarm and repeated alarm. |
|
1182 CArrayPtr< CGulIcon >* iconArray = new( ELeave ) CAknIconArray( KNumOfIcons ); |
|
1183 CleanupStack::PushL( iconArray ); |
|
1184 |
|
1185 CFbsBitmap* iconBitmap( NULL ); |
|
1186 CFbsBitmap* iconMask( NULL ); |
|
1187 CGulIcon* finalIcon( NULL ); |
|
1188 |
|
1189 // First read the alarm icon. |
|
1190 AknsUtils::CreateColorIconL( AknsUtils::SkinInstance(), |
|
1191 KAknsIIDQgnIndiAlarmAdd, |
|
1192 KAknsIIDQsnIconColors, |
|
1193 EAknsCIQsnIconColorsCG13, |
|
1194 iconBitmap, |
|
1195 iconMask, |
|
1196 AknIconUtils::AvkonIconFileName(), |
|
1197 EMbmAvkonQgn_indi_alarm_add, |
|
1198 EMbmAvkonQgn_indi_alarm_add_mask, |
|
1199 TRgb( NULL, NULL, 255 ) ); |
|
1200 CleanupStack::PushL( iconBitmap ); |
|
1201 CleanupStack::PushL( iconMask ); |
|
1202 // Construct the icon. |
|
1203 finalIcon = CGulIcon::NewL( iconBitmap, iconMask ); |
|
1204 CleanupStack::PushL( finalIcon ); |
|
1205 // Append the above icon to the array. |
|
1206 iconArray->AppendL( finalIcon ); |
|
1207 // Cleanup. |
|
1208 CleanupStack::Pop( finalIcon ); |
|
1209 CleanupStack::Pop( iconMask ); |
|
1210 CleanupStack::Pop( iconBitmap ); |
|
1211 |
|
1212 // Now load the repeat icon. |
|
1213 iconBitmap = NULL; |
|
1214 iconMask = NULL; |
|
1215 |
|
1216 AknsUtils::CreateColorIconL( AknsUtils::SkinInstance(), |
|
1217 KAknsIIDQgnIndiRepeatAdd, |
|
1218 KAknsIIDQsnIconColors, |
|
1219 EAknsCIQsnIconColorsCG13, |
|
1220 iconBitmap, |
|
1221 iconMask, |
|
1222 KIconFileName, |
|
1223 EMbmClockappQgn_indi_repeat_add, |
|
1224 EMbmClockappQgn_indi_repeat_add_mask, |
|
1225 TRgb( NULL, NULL, 255 ) ); |
|
1226 CleanupStack::PushL( iconBitmap ); |
|
1227 CleanupStack::PushL( iconMask ); |
|
1228 // Construct the icon. |
|
1229 finalIcon = NULL; |
|
1230 finalIcon = CGulIcon::NewL( iconBitmap, iconMask ); |
|
1231 CleanupStack::PushL( finalIcon ); |
|
1232 // Append the above icon to the array. |
|
1233 iconArray->AppendL( finalIcon ); |
|
1234 // Cleanup. |
|
1235 CleanupStack::Pop( finalIcon ); |
|
1236 CleanupStack::Pop( iconMask ); |
|
1237 CleanupStack::Pop( iconBitmap ); |
|
1238 |
|
1239 // Read the inactive icon. |
|
1240 iconBitmap = NULL; |
|
1241 iconMask = NULL; |
|
1242 |
|
1243 // Create the color icon for the alarm inactive icon. |
|
1244 AknsUtils::CreateColorIconL( AknsUtils::SkinInstance(), |
|
1245 KAknsIIDQgnIndiAlarmInactiveAdd, |
|
1246 KAknsIIDQsnIconColors, |
|
1247 EAknsCIQsnIconColorsCG13, |
|
1248 iconBitmap, |
|
1249 iconMask, |
|
1250 KIconFileName, |
|
1251 EMbmClockappQgn_indi_alarm_inactive_add, |
|
1252 EMbmClockappQgn_indi_alarm_inactive_add_mask, |
|
1253 TRgb( NULL, NULL, 255 ) ); |
|
1254 CleanupStack::PushL( iconBitmap ); |
|
1255 CleanupStack::PushL( iconMask ); |
|
1256 |
|
1257 // Construct the icon. |
|
1258 finalIcon = CGulIcon::NewL( iconBitmap, iconMask ); |
|
1259 CleanupStack::PushL( finalIcon ); |
|
1260 // Append the above icon to the array. |
|
1261 iconArray->AppendL( finalIcon ); |
|
1262 // Cleanup. |
|
1263 CleanupStack::Pop( finalIcon ); |
|
1264 CleanupStack::Pop( iconMask ); |
|
1265 CleanupStack::Pop( iconBitmap ); |
|
1266 |
|
1267 // Now load a blank icon. |
|
1268 iconBitmap = new( ELeave ) CFbsBitmap(); |
|
1269 CleanupStack::PushL( iconBitmap ); |
|
1270 iconMask = new( ELeave ) CFbsBitmap(); |
|
1271 CleanupStack::PushL( iconMask ); |
|
1272 |
|
1273 iconBitmap->Create( TSize( NULL, NULL ), ENone ); |
|
1274 iconMask->Create( TSize( NULL, NULL ), ENone ); |
|
1275 |
|
1276 // Construct the icon. |
|
1277 finalIcon = NULL; |
|
1278 finalIcon = CGulIcon::NewL( iconBitmap, iconMask ); |
|
1279 CleanupStack::PushL( finalIcon ); |
|
1280 // Append it to the icon array. |
|
1281 iconArray->AppendL( finalIcon ); |
|
1282 // Cleanup. |
|
1283 CleanupStack::Pop( finalIcon ); |
|
1284 CleanupStack::Pop( iconMask ); |
|
1285 CleanupStack::Pop( iconBitmap ); |
|
1286 |
|
1287 // Construct the listbox. |
|
1288 //Single click integration |
|
1289 iListBox = new( ELeave ) CAknDoubleStyleListBox; |
|
1290 |
|
1291 iListBox->ConstructL( this, NULL ); |
|
1292 iListBox->SetContainerWindowL( *this ); |
|
1293 |
|
1294 // Set the display properties of the listbox. |
|
1295 iListBox->CreateScrollBarFrameL( ETrue ); |
|
1296 iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, |
|
1297 CEikScrollBarFrame::EAuto ); |
|
1298 iListBox->Model()->SetItemTextArray( iAlarmArray ); |
|
1299 iListBox->ItemDrawer()->FormattedCellData()->SetIconArray( iconArray ); |
|
1300 iListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
1301 |
|
1302 // Set the observer of the listbox events. |
|
1303 iListBox->SetListBoxObserver( this ); |
|
1304 //Single click integration |
|
1305 // Disable list stretching so alarm items are displayed correctly |
|
1306 iListBox->EnableStretching( EFalse ); |
|
1307 |
|
1308 |
|
1309 |
|
1310 // Set the listbox layout. |
|
1311 TAknLayoutRect listBoxRect; |
|
1312 TInt layoutOrientation = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0; |
|
1313 |
|
1314 TAknLayoutRect listRect; |
|
1315 // Get the main clock rect. |
|
1316 listRect.LayoutRect( aRect, AknLayoutScalable_Apps::listscroll_gen_pane_cp06( layoutOrientation ).LayoutLine() ); |
|
1317 |
|
1318 // Get the skinnable clock rect. |
|
1319 listBoxRect.LayoutRect( listRect.Rect(), AknLayoutScalable_Apps::listscroll_gen_pane_cp06( layoutOrientation ).LayoutLine() ); |
|
1320 iListBox->SetRect( listBoxRect.Rect() );//.iTl, listBoxRect.Rect().Size() ); |
|
1321 |
|
1322 // Set the empty list text. |
|
1323 iListBox->View()->SetListEmptyTextL( _L("") ); |
|
1324 iListBox->ActivateL(); |
|
1325 |
|
1326 // Cleanup. |
|
1327 CleanupStack::Pop( iconArray ); |
|
1328 |
|
1329 // construct the "New Alarm" button |
|
1330 iNewAlarmButton = CAknButton::NewL( NULL, NULL, NULL, NULL, |
|
1331 iAlarmArray->NewAlarmText()->Des(), KNullDesC, 0, 0 ); |
|
1332 iNewAlarmButton->SetParent( this ); |
|
1333 iNewAlarmButton->SetContainerWindowL( *this ); |
|
1334 SetCorrectRectForNewAlarmButton(); |
|
1335 iNewAlarmButton->SetObserver( this ); |
|
1336 iNewAlarmButton->ActivateL(); |
|
1337 // Add the icon for DST indicator. |
|
1338 AknsUtils::CreateColorIconL( AknsUtils::SkinInstance(), |
|
1339 KAknsIIDQgnIndiDstAdd, |
|
1340 KAknsIIDQsnIconColors, |
|
1341 EAknsCIQsnIconColorsCG13, |
|
1342 iDstIndicator, |
|
1343 iDstIndicatorMask, |
|
1344 AknIconUtils::AvkonIconFileName(), |
|
1345 EMbmAvkonQgn_indi_dst_add, |
|
1346 EMbmAvkonQgn_indi_dst_add_mask, |
|
1347 TRgb( NULL, NULL, 255 ) ); |
|
1348 |
|
1349 iLocationLabel = new ( ELeave ) CClockMarqueeLabel(); |
|
1350 iLocationLabel->SetContainerWindowL( *this ); |
|
1351 iLocationLabel->ConstructL( ETrue ); |
|
1352 iLocationLabel->SetTextL( KNullDesC ); |
|
1353 iLocationLabel->SetBackground( iBgContext ); |
|
1354 iLocationLabel->MakeVisible( ETrue ); |
|
1355 |
|
1356 TAknLayoutRect mainRect; |
|
1357 // Get the main clock rect. |
|
1358 mainRect.LayoutRect( aRect, AknLayoutScalable_Apps::main_clock2_pane().LayoutLine() ); |
|
1359 |
|
1360 TAknLayoutRect skinClockRect; |
|
1361 TInt displayOrientation( Layout_Meta_Data::IsLandscapeOrientation() ? KVGALandscapeVariant : KVGAPortraitVariant ); |
|
1362 // Get the skinnable clock rect. |
|
1363 skinClockRect.LayoutRect( mainRect.Rect(), |
|
1364 AknLayoutScalable_Apps::popup_clock_analogue_window_cp03( displayOrientation ).LayoutLine() ); |
|
1365 |
|
1366 // Construct the skinnable clock. |
|
1367 iSkinnableClock = CAknSkinnableClock::NewL( this, ETrue, EFalse ); |
|
1368 // Set the size of the clock. |
|
1369 iSkinnableClock->SetExtent( skinClockRect.Rect().iTl, skinClockRect.Rect().Size() ); |
|
1370 |
|
1371 SetRect( aRect ); |
|
1372 |
|
1373 iSkinnableClock->ActivateL(); |
|
1374 |
|
1375 __PRINTS( "CClockMainContainer::ConstructL - Exit" ); |
|
1376 } |
|
1377 |
|
1378 // --------------------------------------------------------- |
|
1379 // CClockMainContainer::CClockMainContainer |
|
1380 // rest of the details are commented in the header |
|
1381 // --------------------------------------------------------- |
|
1382 // |
|
1383 CClockMainContainer::CClockMainContainer() |
|
1384 { |
|
1385 __PRINTS( "CClockMainContainer::CClockMainContainer - Entry" ); |
|
1386 |
|
1387 // No implementation yet. |
|
1388 |
|
1389 __PRINTS( "CClockMainContainer::CClockMainContainer - Exit" ); |
|
1390 } |
|
1391 |
|
1392 // --------------------------------------------------------- |
|
1393 // CClockMainContainer::DrawMainViewText |
|
1394 // rest of the details are commented in the header |
|
1395 // --------------------------------------------------------- |
|
1396 // |
|
1397 void CClockMainContainer::DrawMainViewText( CWindowGc& aWindowGc ) const |
|
1398 { |
|
1399 __PRINTS( "CClockMainContainer::DrawMainViewText - Entry" ); |
|
1400 |
|
1401 TAknLayoutText layoutText; |
|
1402 MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance(); |
|
1403 TRgb cachedColor; |
|
1404 TInt displayOrientation( Layout_Meta_Data::IsLandscapeOrientation() ? KVGALandscapeVariant : KVGAPortraitVariant ); |
|
1405 |
|
1406 // Get the cached color. |
|
1407 AknsUtils::GetCachedColor( skinInstance, cachedColor, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6 ); |
|
1408 |
|
1409 TAknLayoutRect parentRect; |
|
1410 parentRect.LayoutRect( Rect(), AknLayoutScalable_Apps::main_clock2_pane().LayoutLine() ); |
|
1411 |
|
1412 TRect mainClockPane( parentRect.Rect() ); |
|
1413 |
|
1414 if( Layout_Meta_Data::IsLandscapeOrientation() ) |
|
1415 { |
|
1416 // main_clock2_pane_cp01_t1 Day + date |
|
1417 HBufC* dayAndDateString = HBufC::NewLC( iDayNameString->Length() + iDateString->Length() + 1 ); |
|
1418 TPtr dayAndDateStringPtr = dayAndDateString->Des(); |
|
1419 dayAndDateStringPtr.Append( *iDayNameString ); |
|
1420 dayAndDateStringPtr.Append( KSpace ); |
|
1421 TPtr dateStringPtr = iDateString->Des(); |
|
1422 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( dateStringPtr ); |
|
1423 dayAndDateStringPtr.Append( *iDateString ); |
|
1424 |
|
1425 layoutText.LayoutText( mainClockPane, AknLayoutScalable_Apps::main_clock2_pane_cp01_t1( displayOrientation ).LayoutLine() ); |
|
1426 layoutText.DrawText( aWindowGc, *dayAndDateString , ETrue, cachedColor ); |
|
1427 |
|
1428 CleanupStack::PopAndDestroy( dayAndDateString ); |
|
1429 dayAndDateString = NULL; |
|
1430 |
|
1431 // main_clock2_pane_cp01_t3 zone + country |
|
1432 HBufC* timeZoneAndCountryString = HBufC::NewLC( iTimeZoneString->Length() + iLocationString->Length() + 1 ); |
|
1433 TPtr timeZoneAndCountryStringPtr = timeZoneAndCountryString->Des(); |
|
1434 TPtr timeZoneStringPtr = iTimeZoneString->Des(); |
|
1435 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( timeZoneStringPtr ); |
|
1436 timeZoneAndCountryStringPtr.Append( *iTimeZoneString ); |
|
1437 timeZoneAndCountryStringPtr.Append( KSpace ); |
|
1438 timeZoneAndCountryStringPtr.Append( *iLocationString ); |
|
1439 |
|
1440 layoutText.LayoutText( mainClockPane, AknLayoutScalable_Apps::main_clock2_pane_cp01_t3( displayOrientation ).LayoutLine() ); |
|
1441 layoutText.DrawText( aWindowGc, *timeZoneAndCountryString, ETrue, cachedColor ); |
|
1442 /* |
|
1443 TAknTextComponentLayout labelLayout; |
|
1444 labelLayout = AknLayoutScalable_Apps::main_clock2_pane_cp01_t3( Layout_Meta_Data::IsLandscapeOrientation() ); |
|
1445 AknLayoutUtils::LayoutLabel( iLocationLabel, parentRect.Rect(), labelLayout.LayoutLine() ); |
|
1446 |
|
1447 // Set the label for the text and start marqueeing. |
|
1448 iLocationLabel->SetLabelTextL( *timeZoneAndCountryString ); |
|
1449 TGulAlignment alignment; |
|
1450 alignment.SetHAlignment( EHCenter ); |
|
1451 iLocationLabel->SetAlignment( alignment ); |
|
1452 iLocationLabel->StartMarquee(); |
|
1453 iLocationLabel->RedrawRect( iLocationLabel->Rect() ); |
|
1454 */ |
|
1455 CleanupStack::PopAndDestroy( timeZoneAndCountryString ); |
|
1456 timeZoneAndCountryString = NULL; |
|
1457 } |
|
1458 else |
|
1459 { |
|
1460 // Get the layout for the day string. |
|
1461 layoutText.LayoutText( mainClockPane, AknLayoutScalable_Apps::main_clock2_pane_t1( displayOrientation ).LayoutLine() ); |
|
1462 |
|
1463 TPtr dayStringPtr = iDayNameString->Des(); |
|
1464 // Day long format. |
|
1465 layoutText.DrawText( aWindowGc, *iDayNameString, ETrue, cachedColor ); |
|
1466 |
|
1467 // Get the layout for the datestring. |
|
1468 layoutText.LayoutText( mainClockPane, AknLayoutScalable_Apps::main_clock2_pane_t2( displayOrientation ).LayoutLine() ); |
|
1469 |
|
1470 TPtr dateStringPtr = iDateString->Des(); |
|
1471 // For mirrored languages. |
|
1472 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( dateStringPtr ); |
|
1473 // Date long format |
|
1474 layoutText.DrawText( aWindowGc, *iDateString, ETrue, cachedColor ); |
|
1475 |
|
1476 // Get the layout for the timezone string. |
|
1477 layoutText.LayoutText( mainClockPane, AknLayoutScalable_Apps::main_clock2_pane_t3( Layout_Meta_Data::IsLandscapeOrientation() ).LayoutLine() ); |
|
1478 |
|
1479 TPtr timeZonePtr = iTimeZoneString->Des(); |
|
1480 // This is for mirrored languages. |
|
1481 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( timeZonePtr ); |
|
1482 // The timezone string. |
|
1483 layoutText.DrawText( aWindowGc, *iTimeZoneString, ETrue, cachedColor ); |
|
1484 |
|
1485 // Get the layout for the country string. |
|
1486 TAknTextComponentLayout labelLayout; |
|
1487 labelLayout = AknLayoutScalable_Apps::main_clock2_pane_t4( Layout_Meta_Data::IsLandscapeOrientation() ); |
|
1488 AknLayoutUtils::LayoutLabel( iLocationLabel, parentRect.Rect(), labelLayout.LayoutLine() ); |
|
1489 |
|
1490 // Set the label for the text and start marqueeing. |
|
1491 iLocationLabel->SetLabelTextL( *iLocationString ); |
|
1492 iLocationLabel->StartMarquee(); |
|
1493 iLocationLabel->RedrawRect( iLocationLabel->Rect() ); |
|
1494 } |
|
1495 __PRINTS( "CClockMainContainer::DrawMainViewText - Exit" ); |
|
1496 } |
|
1497 |
|
1498 // --------------------------------------------------------- |
|
1499 // CClockMainContainer::IsDstOnL |
|
1500 // rest of the details are commented in the header |
|
1501 // --------------------------------------------------------- |
|
1502 // |
|
1503 TBool CClockMainContainer::IsDstOnL( TInt aTimeZoneId ) |
|
1504 { |
|
1505 __PRINTS( "CClockMainContainer::IsDstOnL - Entry" ); |
|
1506 |
|
1507 TBool returnVal( EFalse ); |
|
1508 CTzId* timeZoneId = CTzId::NewL( aTimeZoneId ); |
|
1509 CleanupStack::PushL( timeZoneId ); |
|
1510 |
|
1511 RTz tzHandle; |
|
1512 User::LeaveIfError( tzHandle.Connect() ); |
|
1513 CleanupClosePushL( tzHandle ); |
|
1514 |
|
1515 returnVal = tzHandle.IsDaylightSavingOnL( *timeZoneId ); |
|
1516 |
|
1517 tzHandle.Close(); |
|
1518 CleanupStack::PopAndDestroy( &tzHandle ); |
|
1519 CleanupStack::PopAndDestroy( timeZoneId ); |
|
1520 |
|
1521 __PRINTS( "CClockMainContainer::IsDstOnL - Exit" ); |
|
1522 |
|
1523 return returnVal; |
|
1524 } |
|
1525 |
|
1526 // --------------------------------------------------------- |
|
1527 // CClockMainContainer::GetOffSetWithDstL |
|
1528 // rest of the details are commented in the header |
|
1529 // --------------------------------------------------------- |
|
1530 // |
|
1531 void CClockMainContainer::GetOffSetWithDstL( TInt32& aDstOffset, const CTzId& aTzId ) |
|
1532 { |
|
1533 __PRINTS( "CClockMainContainer::GetOffSetWithDstL - Entry" ); |
|
1534 |
|
1535 RTz rTz; |
|
1536 User::LeaveIfError( rTz.Connect() ); |
|
1537 CleanupClosePushL( rTz ); |
|
1538 |
|
1539 // Local time |
|
1540 TTime homeTime; |
|
1541 homeTime.HomeTime(); |
|
1542 |
|
1543 TDateTime dateTime; |
|
1544 dateTime = homeTime.DateTime(); |
|
1545 |
|
1546 // Get the CTzRules for the current year and for the given time zone id. |
|
1547 CTzRules* tzRules = rTz.GetTimeZoneRulesL( aTzId, |
|
1548 dateTime.Year(), |
|
1549 dateTime.Year(), |
|
1550 ETzWallTimeReference ); |
|
1551 CleanupStack::PushL( tzRules ); |
|
1552 |
|
1553 // Get the Actualised rules for the same year. These are the DST rules from which we get the iNewOffset. |
|
1554 CVTzActualisedRules *vActualisedRules = CVTzActualisedRules::NewL( |
|
1555 homeTime.DateTime().Year(), |
|
1556 homeTime.DateTime().Year() ); |
|
1557 CleanupStack::PushL( vActualisedRules ); |
|
1558 tzRules->GetActualisedRulesL( *vActualisedRules ); |
|
1559 |
|
1560 // This way of fetching initial offset is being used rather than tzRules->InitialStdTimeOffset() |
|
1561 // because in some cases, the offset returned is incorrect. (For ex: Argentina and Canada/Iqaluit) |
|
1562 RArray< TInt > timeZones; |
|
1563 RArray< TInt > zoneOffsets; |
|
1564 |
|
1565 // Append the current timezone ID and request for the standard offset |
|
1566 timeZones.Append( aTzId.TimeZoneNumericID() ); |
|
1567 rTz.GetOffsetsForTimeZoneIdsL( timeZones, zoneOffsets ); |
|
1568 |
|
1569 // The initial offset or the standard offset (w/o DST) |
|
1570 TInt initialTimeZoneOffset = zoneOffsets[ 0 ]; |
|
1571 |
|
1572 // Close the resource handles |
|
1573 timeZones.Close(); |
|
1574 zoneOffsets.Close(); |
|
1575 |
|
1576 // The number of actualised rules |
|
1577 TInt ruleCount = vActualisedRules->Count(); |
|
1578 |
|
1579 for( TInt ruleIndex( KZerothRule ); ruleIndex < ruleCount; ruleIndex++ ) |
|
1580 { |
|
1581 const TVTzActualisedRule& tVTzactRule = ( *vActualisedRules )[ ruleIndex ]; |
|
1582 |
|
1583 // If the standard offset and the new offset do not match then we have a dst offset. |
|
1584 // Technically if a timezone has DST then it can have a max of two offsets. One is the standard which doesn't show the |
|
1585 // DST usage, and the other is the DST offset which is standard offset + the amount of DST |
|
1586 if( initialTimeZoneOffset != tVTzactRule.iNewOffset ) |
|
1587 { |
|
1588 aDstOffset = tVTzactRule.iNewOffset; |
|
1589 CleanupStack::PopAndDestroy( vActualisedRules ); |
|
1590 CleanupStack::PopAndDestroy( tzRules ); |
|
1591 CleanupStack::PopAndDestroy( &rTz ); |
|
1592 |
|
1593 __PRINTS( "CClockMainContainer::GetOffSetWithDstL - Exit" ); |
|
1594 |
|
1595 return; |
|
1596 } |
|
1597 } |
|
1598 CleanupStack::PopAndDestroy( vActualisedRules ); |
|
1599 CleanupStack::PopAndDestroy( tzRules ); |
|
1600 CleanupStack::PopAndDestroy( &rTz ); |
|
1601 |
|
1602 __PRINTS( "CClockMainContainer::GetOffSetWithDstL - Exit" ); |
|
1603 } |
|
1604 |
|
1605 // --------------------------------------------------------- |
|
1606 // CClockMainContainer::GetHelpContext |
|
1607 // rest of the details are commented in the header |
|
1608 // --------------------------------------------------------- |
|
1609 // |
|
1610 void CClockMainContainer::GetHelpContext( TCoeHelpContext& aContext ) const |
|
1611 { |
|
1612 aContext.iMajor = KClockAppUid; |
|
1613 if( GetAutoTimeUpdateState () ) |
|
1614 { |
|
1615 aContext.iContext = KCLK_HLP_REAL_TIME_CLOCK_AN; |
|
1616 } |
|
1617 else |
|
1618 { |
|
1619 aContext.iContext = KCLK_HLP_REAL_TIME_CLOCK_IN; |
|
1620 } |
|
1621 } |
|
1622 |
|
1623 // --------------------------------------------------------- |
|
1624 // CClockMainContainer::GetAutoTimeUpdateState |
|
1625 // rest of the details are commented in the header |
|
1626 // --------------------------------------------------------- |
|
1627 // |
|
1628 TBool CClockMainContainer::GetAutoTimeUpdateState() const |
|
1629 { |
|
1630 // Check if automatic time update is enabled. |
|
1631 TBool timeUpdateOn( EFalse ); |
|
1632 RClkSrvInterface clkSrvIf; |
|
1633 |
|
1634 // Connect to clockserver |
|
1635 TInt errorVal( clkSrvIf.Connect() ); |
|
1636 |
|
1637 if( KErrNone == errorVal ) |
|
1638 { |
|
1639 // First check if automatic time update is enabled. |
|
1640 errorVal = clkSrvIf.IsAutoTimeUpdateOn( timeUpdateOn ); |
|
1641 } |
|
1642 return timeUpdateOn; |
|
1643 } |
|
1644 |
|
1645 void CClockMainContainer::HandleControlEventL( CCoeControl* aControl, |
|
1646 TCoeEvent aEventType ) |
|
1647 { |
|
1648 if ( aControl == iNewAlarmButton && aEventType == MCoeControlObserver::EEventStateChanged |
|
1649 && iView && !iView->IsAlarmEditorOpen() ) |
|
1650 { |
|
1651 iView->HandleCommandL( EClockNewAlarm ); |
|
1652 } |
|
1653 } |
|
1654 |
|
1655 void CClockMainContainer::SetCorrectRectForNewAlarmButton() |
|
1656 { |
|
1657 if( iNewAlarmButton ) |
|
1658 { |
|
1659 TRect paneRect = this->Rect(); |
|
1660 TAknLayoutRect newAlarmButtonRect; |
|
1661 TAknLayoutRect mainRect; |
|
1662 TInt displayOrientation( Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0 ); |
|
1663 // Get the layout for the main rect. |
|
1664 mainRect.LayoutRect( paneRect, |
|
1665 AknLayoutScalable_Apps::main_clock2_pane().LayoutLine() ); |
|
1666 if( displayOrientation ) |
|
1667 { |
|
1668 // landscape |
|
1669 TInt alarmCount( 0 ); |
|
1670 if( iListBox ) |
|
1671 { |
|
1672 alarmCount = iListBox->Model()->ItemTextArray()->MdcaCount(); |
|
1673 } |
|
1674 if( alarmCount > 0 ) |
|
1675 { |
|
1676 if( iListBox ) |
|
1677 { |
|
1678 iListBox->MakeVisible( ETrue ); |
|
1679 } |
|
1680 // landscape if not empty alarm list |
|
1681 newAlarmButtonRect.LayoutRect( mainRect.Rect(), |
|
1682 AknLayoutScalable_Apps::main_clock2_btn_pane( displayOrientation ).LayoutLine() ); |
|
1683 } |
|
1684 else |
|
1685 { |
|
1686 // landscape if empty alarm list |
|
1687 if( iListBox ) |
|
1688 { |
|
1689 iListBox->MakeVisible( EFalse ); |
|
1690 } |
|
1691 newAlarmButtonRect.LayoutRect( mainRect.Rect(), |
|
1692 AknLayoutScalable_Apps::main_clock2_btn_pane_cp01( displayOrientation ).LayoutLine() ); |
|
1693 } |
|
1694 } |
|
1695 else |
|
1696 { |
|
1697 // portrait |
|
1698 if( iListBox ) |
|
1699 { |
|
1700 iListBox->MakeVisible( ETrue ); |
|
1701 } |
|
1702 newAlarmButtonRect.LayoutRect( mainRect.Rect(), |
|
1703 AknLayoutScalable_Apps::main_clock2_btn_pane( displayOrientation ).LayoutLine() ); |
|
1704 } |
|
1705 iNewAlarmButton->SetRect( newAlarmButtonRect.Rect() ); |
|
1706 } |
|
1707 |
|
1708 } |
|
1709 |
|
1710 void CClockMainContainer::SwitchClockTypeL() |
|
1711 { |
|
1712 TRect skinClockRect = iSkinnableClock->Rect(); |
|
1713 delete iSkinnableClock; |
|
1714 iSkinnableClock = NULL; |
|
1715 // Construct the skinnable clock. |
|
1716 iSkinnableClock = CAknSkinnableClock::NewL( this, ETrue, EFalse ); |
|
1717 // Set the size of the clock. |
|
1718 iSkinnableClock->SetExtent( skinClockRect.iTl, skinClockRect.Size() ); |
|
1719 iSkinnableClock->ActivateL(); |
|
1720 iSkinnableClock->DrawDeferred(); |
|
1721 } |
|
1722 |
|
1723 TBool CClockMainContainer::IsNewAlaramButtonFocused() |
|
1724 { |
|
1725 __PRINTS( "CClockMainContainer::IsNewAlaramFocused - Entry" ); |
|
1726 |
|
1727 return (iNewAlarmButton->IsFocused()); |
|
1728 |
|
1729 __PRINTS( "CClockMainContainer::IsNewAlaramFocused - Exit" ); |
|
1730 |
|
1731 } |
|
1732 // End of file |