clock2/clockui/uilayer/clockmainview/src/clockmaincontainer.cpp
branchRCL_3
changeset 30 d68a4b5d5885
parent 0 f979ecb2b13e
child 36 9c5b1510919f
equal deleted inserted replaced
27:55d60436f00b 30:d68a4b5d5885
    36 #include <avkon.mbg>
    36 #include <avkon.mbg>
    37 #include <tz.h>
    37 #include <tz.h>
    38 #include <tzlocalizer.h>
    38 #include <tzlocalizer.h>
    39 #include <tzlocalizationdatatypes.h>
    39 #include <tzlocalizationdatatypes.h>
    40 #include <vtzrules.h>
    40 #include <vtzrules.h>
       
    41 #include <aknbutton.h>
    41 
    42 
    42 // User includes
    43 // User includes
    43 #include "clockmaincontainer.h"
    44 #include "clockmaincontainer.h"
    44 #include "clockmainview.h"
    45 #include "clockmainview.h"
    45 #include "clockalarmarray.h"
    46 #include "clockalarmarray.h"
    65     R_QTN_WEEK_LONG_THURSDAY,
    66     R_QTN_WEEK_LONG_THURSDAY,
    66     R_QTN_WEEK_LONG_FRIDAY,
    67     R_QTN_WEEK_LONG_FRIDAY,
    67     R_QTN_WEEK_LONG_SATURDAY,
    68     R_QTN_WEEK_LONG_SATURDAY,
    68     R_QTN_WEEK_LONG_SUNDAY
    69     R_QTN_WEEK_LONG_SUNDAY
    69     };
    70     };
       
    71 
       
    72 TInt const KSwitchDelay = 200*1000;
    70 
    73 
    71 // Literals
    74 // Literals
    72 _LIT( KIconFileName, "\\resource\\apps\\clockapp.mif" );
    75 _LIT( KIconFileName, "\\resource\\apps\\clockapp.mif" );
    73 _LIT( KPlusGMT, " \x202A+" );
    76 _LIT( KPlusGMT, " \x202A+" );
    74 _LIT( KMinusGMT, " \x202A" );
    77 _LIT( KMinusGMT, " \x202A" );
   153 	if( iTimeZoneString )
   156 	if( iTimeZoneString )
   154 	    {
   157 	    {
   155 	    delete iTimeZoneString;
   158 	    delete iTimeZoneString;
   156 	    iTimeZoneString = NULL;
   159 	    iTimeZoneString = NULL;
   157 	    }
   160 	    }
   158 		
   161 
       
   162 	delete iNewAlarmButton;
       
   163 	iNewAlarmButton = NULL;
   159 	__PRINTS( "CClockMainContainer::~CClockMainContainer - Exit" );
   164 	__PRINTS( "CClockMainContainer::~CClockMainContainer - Exit" );
   160     }
   165     }
   161 
   166 
   162 // ---------------------------------------------------------
   167 // ---------------------------------------------------------
   163 // CClockMainContainer::OfferKeyEventL
   168 // CClockMainContainer::OfferKeyEventL
   187             }
   192             }
   188         
   193         
   189         if( EKeyUpArrow == aKeyEvent.iCode ||
   194         if( EKeyUpArrow == aKeyEvent.iCode ||
   190             EKeyDownArrow == aKeyEvent.iCode )
   195             EKeyDownArrow == aKeyEvent.iCode )
   191             {
   196             {
   192             if( iListBox )
   197 
   193                 {
   198             TInt itemCount = iListBox->Model()->ItemTextArray()->MdcaCount();
   194     
   199             // if neither has focus just then select button to be focused
   195                     
   200             if( !iNewAlarmButton->IsFocused() && !iListBox->IsFocused() )
       
   201                 {
       
   202                 iListBox->View()->ItemDrawer()->SetFlags( CListItemDrawer::EDisableHighlight );
       
   203                 iNewAlarmButton->SetFocus( ETrue );
       
   204                 DrawDeferred();
       
   205                 retVal = EKeyWasConsumed;
       
   206                 }
       
   207             // button not focused and no list items -> set focus to button
       
   208             else if( itemCount == 0 && !iNewAlarmButton->IsFocused() )
       
   209                 {
       
   210                 iListBox->View()->ItemDrawer()->SetFlags( CListItemDrawer::EDisableHighlight );
       
   211                 iListBox->SetFocus( EFalse );
       
   212                 iNewAlarmButton->SetFocus( ETrue );
       
   213                 DrawDeferred();
       
   214                 retVal = EKeyWasConsumed;
       
   215                 }
       
   216             // button focused and listbox has items
       
   217             else if( iNewAlarmButton->IsFocused() && itemCount > 0 )
       
   218                 {
       
   219                 iListBox->View()->ItemDrawer()->ClearFlags( CListItemDrawer::EDisableHighlight );
       
   220                 iNewAlarmButton->SetFocus( EFalse );
       
   221                 iListBox->SetFocus( ETrue );
       
   222                 if( EKeyDownArrow == aKeyEvent.iCode )
       
   223                     {
       
   224                     iListBox->SetCurrentItemIndex( itemCount - 1 );
       
   225                     }
       
   226                 else
       
   227                     {
       
   228                     iListBox->SetCurrentItemIndex( 0 );
       
   229                     }
       
   230                 retVal = iListBox->OfferKeyEventL( aKeyEvent, aType );
       
   231                 }
       
   232             // listbox focused
       
   233             else if( iListBox->IsFocused() && itemCount > 0 )
       
   234                 {
       
   235                 // first item when only one item in the list
       
   236                 if( iListBox->CurrentItemIndex() == 0 && itemCount == 1 )
       
   237                     {
       
   238                     iListBox->View()->ItemDrawer()->SetFlags( CListItemDrawer::EDisableHighlight );
       
   239                     iListBox->SetFocus( EFalse );
       
   240                     iNewAlarmButton->SetFocus( ETrue );
       
   241                     DrawDeferred();
       
   242                     retVal = EKeyWasConsumed;
       
   243                     }
       
   244                 // first item
       
   245                 else if( iListBox->CurrentItemIndex() == 0 && EKeyUpArrow == aKeyEvent.iCode )
       
   246                     {
       
   247                     iListBox->View()->ItemDrawer()->SetFlags( CListItemDrawer::EDisableHighlight );
       
   248                     iListBox->SetFocus( EFalse );
       
   249                     iNewAlarmButton->SetFocus( ETrue );
       
   250                     DrawDeferred();
       
   251                     retVal = EKeyWasConsumed;
       
   252                     }
       
   253                 //last item
       
   254                 else if( iListBox->CurrentItemIndex() == ( itemCount - 1 )
       
   255                         && EKeyDownArrow == aKeyEvent.iCode )
       
   256                     {
       
   257                     iListBox->View()->ItemDrawer()->SetFlags( CListItemDrawer::EDisableHighlight );
       
   258                     iListBox->SetFocus( EFalse);
       
   259                     iNewAlarmButton->SetFocus( ETrue );
       
   260                     DrawDeferred();
       
   261                     retVal = EKeyWasConsumed;
       
   262                     }
   196                 // Send the event to the listbox to handle the event.
   263                 // Send the event to the listbox to handle the event.
   197                 retVal = iListBox->OfferKeyEventL( aKeyEvent, aType );
   264                 else
       
   265                     {
       
   266                     iListBox->View()->ItemDrawer()->ClearFlags( CListItemDrawer::EDisableHighlight );
       
   267                     retVal = iListBox->OfferKeyEventL( aKeyEvent, aType );
       
   268                     }
   198                 }
   269                 }
   199             }
   270             }
   200 
   271 
   201         if( ( EKeyBackspace == aKeyEvent.iCode || EKeyDelete == aKeyEvent.iCode ) &&
   272         if( ( EKeyBackspace == aKeyEvent.iCode || EKeyDelete == aKeyEvent.iCode ) &&
   202             ( KZeroAlarms < iListBox->Model()->ItemTextArray()->MdcaCount() ) )
   273             ( KZeroAlarms < iListBox->Model()->ItemTextArray()->MdcaCount() ) )
   203             {
   274             {
   204             // Handle backspace command. Deletes the selected alarm.
   275             // Handle backspace command. Deletes the selected alarm.
   205 			//Single click integration
   276 			//Single click integration
   206             if ( iView->MenuBar()->ItemSpecificCommandsEnabled() )
   277             if ( iListBox->IsFocused() && iView->MenuBar()->ItemSpecificCommandsEnabled() )
   207                 {
   278                 {
   208                 // if highlighted
   279                 // if highlighted
   209                 iView->HandleCommandL( EClockRemoveAlarm );
   280                 iView->HandleCommandL( EClockRemoveAlarm );
   210                 retVal = EKeyWasConsumed;
   281                 retVal = EKeyWasConsumed;
   211                 }
   282                 }
   213 
   284 
   214             }
   285             }
   215 		//Single click integration
   286 		//Single click integration
   216         if ( aKeyEvent.iCode == EKeyOK || aKeyEvent.iCode == EKeyEnter )
   287         if ( aKeyEvent.iCode == EKeyOK || aKeyEvent.iCode == EKeyEnter )
   217             {
   288             {
   218             // Send the event to the listbox to handle the event.
   289             // Send the event to the listbox to handle the event
   219             iListBox->OfferKeyEventL( aKeyEvent, aType );
   290             // if listbox is focused
       
   291             if( iListBox->IsFocused() && iListBox->Model()->ItemTextArray()->MdcaCount() > 0 )
       
   292                 {
       
   293                 iListBox->OfferKeyEventL( aKeyEvent, aType );
       
   294                 retVal = EKeyWasConsumed;
       
   295                 }
       
   296             else
       
   297                 {
       
   298                 // default action for the enter is button press
       
   299                 TKeyEvent keyEvent;
       
   300                 keyEvent.iCode = EKeyOK;  
       
   301                 keyEvent.iScanCode = EStdKeyDevice3;
       
   302                 keyEvent.iModifiers = 0;
       
   303                 keyEvent.iRepeats = 0;
       
   304                 iNewAlarmButton->OfferKeyEventL( keyEvent, EEventKeyDown );
       
   305                 iNewAlarmButton->OfferKeyEventL( keyEvent, EEventKey );
       
   306                 iNewAlarmButton->OfferKeyEventL( keyEvent, EEventKeyUp );
       
   307                 retVal = EKeyWasConsumed;
       
   308                 
       
   309                 }
   220             }
   310             }
   221 
   311 
   222         }
   312         }
   223 		
   313 		
   224 	__PRINTS( "CClockMainContainer::OfferKeyEventL - Exit" );
   314 	__PRINTS( "CClockMainContainer::OfferKeyEventL - Exit" );
   278 //
   368 //
   279 void CClockMainContainer::FocusChanged( TDrawNow /*aDrawNow*/ )
   369 void CClockMainContainer::FocusChanged( TDrawNow /*aDrawNow*/ )
   280     {
   370     {
   281 	__PRINTS( "CClockMainContainer::FocusChanged - Entry" );
   371 	__PRINTS( "CClockMainContainer::FocusChanged - Entry" );
   282 	
   372 	
   283     if( iListBox )
       
   284         {
       
   285         iListBox->SetFocus( IsFocused() );
       
   286         }
       
   287 		
       
   288 	__PRINTS( "CClockMainContainer::FocusChanged - Exit" );
   373 	__PRINTS( "CClockMainContainer::FocusChanged - Exit" );
   289     }
   374     }
   290 
   375 
   291 // ---------------------------------------------------------
   376 // ---------------------------------------------------------
   292 // CClockMainContainer::HandlePointerEventL
   377 // CClockMainContainer::HandlePointerEventL
   302         {
   387         {
   303 		__PRINTS( "CClockMainContainer::HandlePointerEventL - Exit" );
   388 		__PRINTS( "CClockMainContainer::HandlePointerEventL - Exit" );
   304 		
   389 		
   305         return;
   390         return;
   306         }
   391         }
   307 
   392     
   308     // Let the listbox handle the event.
   393     // to get the vibes let's handle skinnable clock as a special case
   309     iListBox->HandlePointerEventL( aPointerEvent );
   394     // no need to to delegate pointer events to it
   310 		
   395     if( iSkinnableClock && iSkinnableClock->Rect().Contains( aPointerEvent.iPosition ) )
       
   396         {
       
   397         if( aPointerEvent.iType == TPointerEvent::EButton1Down  )
       
   398             {
       
   399             TTime now;
       
   400             now.HomeTime();
       
   401             TInt64 launchFreq = now.MicroSecondsFrom( iPreviousClockTypeSwitch ).Int64();
       
   402             if( launchFreq > MAKE_TINT64( 0, KSwitchDelay )  )
       
   403                 {
       
   404                 iView->GiveVibes();
       
   405                 iView->HandleCommandL( EClockSwitchClockType ); 
       
   406                 iPreviousClockTypeSwitch.HomeTime();
       
   407                 }   
       
   408             }
       
   409         } 
       
   410     else
       
   411         {
       
   412         CCoeControl::HandlePointerEventL( aPointerEvent );
       
   413         }
   311 	__PRINTS( "CClockMainContainer::HandlePointerEventL - Exit" );
   414 	__PRINTS( "CClockMainContainer::HandlePointerEventL - Exit" );
   312     }
   415     }
   313 
   416 
   314 // ---------------------------------------------------------
   417 // ---------------------------------------------------------
   315 // CClockMainContainer::HandleListBoxEventL
   418 // CClockMainContainer::HandleListBoxEventL
   317 // ---------------------------------------------------------
   420 // ---------------------------------------------------------
   318 //
   421 //
   319 void CClockMainContainer::HandleListBoxEventL( CEikListBox* aListBox, TListBoxEvent aEventType )
   422 void CClockMainContainer::HandleListBoxEventL( CEikListBox* aListBox, TListBoxEvent aEventType )
   320     {
   423     {
   321     __PRINTS( "CClockMainContainer::HandleListBoxEventL - Entry" );
   424     __PRINTS( "CClockMainContainer::HandleListBoxEventL - Entry" );
   322 
       
   323     if( aListBox == iListBox &&
   425     if( aListBox == iListBox &&
   324         aEventType == EEventItemSingleClicked )
   426         ( aEventType == EEventItemSingleClicked || aEventType == EEventEnterKeyPressed ) )
   325         {
   427         {
   326         // Check if the user has double clicked on the list item.
   428         // Check if the user has double clicked on the list item.
   327         if( !iView->IsAlarmEditorOpen() )
   429         if( !iView->IsAlarmEditorOpen() )
   328             {
   430             {
   329             // If the user has selected the first item, launch alarm editor.
   431             iView->HandleCommandL( EClockResetAlarm ); 
   330             if( KErrNone == aListBox->CurrentItemIndex() )
   432             }
   331                 {
   433         }
   332                 iView->HandleCommandL( EClockNewAlarm );
       
   333                 }
       
   334             else
       
   335                 {
       
   336 				//Single click integration
       
   337                 iView->HandleCommandL( EClockResetAlarm ); 
       
   338 
       
   339                 }
       
   340             }
       
   341         }
       
   342 	//Single click integration
       
   343     else if ( aListBox == iListBox && aEventType == EEventEnterKeyPressed )
       
   344         {
       
   345         if( !iView->IsAlarmEditorOpen() )
       
   346             {
       
   347             if ( iListBox->CurrentItemIndex() == 0 ) 
       
   348                 {
       
   349                 iView->HandleCommandL( EClockNewAlarm );
       
   350                 }
       
   351             else 
       
   352                 {
       
   353                 iView->HandleCommandL( EClockResetAlarm ); 
       
   354                 }
       
   355             }
       
   356         }
       
   357 
       
   358     
   434     
   359     __PRINTS( "CClockMainContainer::HandleListBoxEventL - Entry" );
   435     __PRINTS( "CClockMainContainer::HandleListBoxEventL - Entry" );
   360     }
   436     }
   361 
   437 
   362 // ---------------------------------------------------------
   438 // ---------------------------------------------------------
   376     TInt itemIndex( iAlarmArray->ListBoxIndex( aAlarmId ) );
   452     TInt itemIndex( iAlarmArray->ListBoxIndex( aAlarmId ) );
   377     
   453     
   378     // Update the listbox.
   454     // Update the listbox.
   379     iListBox->ScrollToMakeItemVisible( itemIndex );
   455     iListBox->ScrollToMakeItemVisible( itemIndex );
   380     iListBox->SetCurrentItemIndexAndDraw( itemIndex );
   456     iListBox->SetCurrentItemIndexAndDraw( itemIndex );
   381 	
   457     SetCorrectRectForNewAlarmButton();
       
   458     iNewAlarmButton->DrawDeferred();
   382 	__PRINTS( "CClockMainContainer::UpdateAlarmListL - Exit" );
   459 	__PRINTS( "CClockMainContainer::UpdateAlarmListL - Exit" );
   383     }
   460     }
   384 
   461 
   385 // ---------------------------------------------------------
   462 // ---------------------------------------------------------
   386 // CClockMainContainer::RemoveAlarmL
   463 // CClockMainContainer::RemoveAlarmL
   391     {
   468     {
   392 	__PRINTS( "CClockMainContainer::RemoveAlarmL - Entry" );
   469 	__PRINTS( "CClockMainContainer::RemoveAlarmL - Entry" );
   393 	
   470 	
   394     // Reinitialize the alarm list.
   471     // Reinitialize the alarm list.
   395     iAlarmArray->InitIdList();
   472     iAlarmArray->InitIdList();
   396     
   473     TInt count = iListBox->Model()->ItemTextArray()->MdcaCount();
   397     if( ( KZeroAlarms <= aIndex ) &&
   474     
   398         ( aIndex == iListBox->Model()->ItemTextArray()->MdcaCount() ) )
   475     //SetCorrectRectForNewAlarmButton();
       
   476     
       
   477     // if only one item
       
   478     if( ( KZeroAlarms == aIndex ) && ( aIndex == count ) )
       
   479         {
       
   480         iListBox->SetCurrentItemIndex( KZeroAlarms );
       
   481         SetCorrectRectForNewAlarmButton();
       
   482         }  
       
   483     // last item when more than one exists
       
   484     else if( ( KZeroAlarms < aIndex ) && ( aIndex == count ) )
   399         {
   485         {
   400         // Last alarm in the list is deleted hence set the previous alarm.
   486         // Last alarm in the list is deleted hence set the previous alarm.
   401         iListBox->ScrollToMakeItemVisible( aIndex - 1 );
   487         iListBox->ScrollToMakeItemVisible( aIndex - 1 );
   402         iListBox->SetCurrentItemIndexAndDraw( aIndex - 1 );
   488         iListBox->SetCurrentItemIndexAndDraw( aIndex - 1 );
   403         
   489         iListBox->HandleItemRemovalL();
   404         
   490         DrawNow();
   405         }
   491         }
   406     else if( ( KZeroAlarms <= aIndex ) &&
   492     // not last item
   407              ( KZeroAlarms < iListBox->Model()->ItemTextArray()->MdcaCount() ) )
   493     else if( ( KZeroAlarms <= aIndex ) && ( aIndex < count ) )
   408         {
   494         {
   409         // Highlight the alarm item replacing the deleted element
   495         // Highlight the alarm item replacing the deleted element
   410         iListBox->ScrollToMakeItemVisible( aIndex );
   496         iListBox->ScrollToMakeItemVisible( aIndex );
   411         iListBox->SetCurrentItemIndexAndDraw( aIndex );
   497         iListBox->SetCurrentItemIndexAndDraw( aIndex );
   412         }
   498         iListBox->HandleItemRemovalL();
   413     
   499         DrawNow();
   414     // Update the listbox.
   500         }
   415     iListBox->HandleItemRemovalL();
       
   416     DrawNow();
       
   417 	
   501 	
   418 	__PRINTS( "CClockMainContainer::RemoveAlarmL - Exit" );
   502 	__PRINTS( "CClockMainContainer::RemoveAlarmL - Exit" );
   419     }
   503     }
   420 
   504 
   421 // ---------------------------------------------------------
   505 // ---------------------------------------------------------
   766         listBoxRect.LayoutRect( mainRect.Rect(), AknLayoutScalable_Apps::listscroll_gen_pane_cp06( 0 ).LayoutLine() );
   850         listBoxRect.LayoutRect( mainRect.Rect(), AknLayoutScalable_Apps::listscroll_gen_pane_cp06( 0 ).LayoutLine() );
   767         skinClockRect.LayoutRect( mainRect.Rect(),
   851         skinClockRect.LayoutRect( mainRect.Rect(),
   768                                   AknLayoutScalable_Apps::popup_clock_analogue_window_cp03( KVGAPortraitVariant ).LayoutLine() );
   852                                   AknLayoutScalable_Apps::popup_clock_analogue_window_cp03( KVGAPortraitVariant ).LayoutLine() );
   769         }
   853         }
   770     
   854     
       
   855     SetCorrectRectForNewAlarmButton();
       
   856     
   771     // Update the skinnable clock.
   857     // Update the skinnable clock.
   772     iSkinnableClock->SetExtent( skinClockRect.Rect().iTl, skinClockRect.Rect().Size() );
   858     iSkinnableClock->SetExtent( skinClockRect.Rect().iTl, skinClockRect.Rect().Size() );
   773     iSkinnableClock->UpdateDisplay();
   859     iSkinnableClock->UpdateDisplay();
   774     
   860     
   775     // Update the listbox.
   861     // Update the listbox.
   787     {
   873     {
   788 	__PRINTS( "CClockMainContainer::CountComponentControls - Entry" );
   874 	__PRINTS( "CClockMainContainer::CountComponentControls - Entry" );
   789 	
   875 	
   790 	__PRINTS( "CClockMainContainer::CountComponentControls - Exit" );
   876 	__PRINTS( "CClockMainContainer::CountComponentControls - Exit" );
   791 	
   877 	
   792     return 2;
   878     return 3;
   793     }
   879     }
   794 
   880 
   795 // ---------------------------------------------------------
   881 // ---------------------------------------------------------
   796 // CClockMainContainer::ComponentControl
   882 // CClockMainContainer::ComponentControl
   797 // rest of the details are commented in the header
   883 // rest of the details are commented in the header
   811             return iSkinnableClock;
   897             return iSkinnableClock;
   812             }
   898             }
   813             
   899             
   814         case 1:
   900         case 1:
   815             {
   901             {
       
   902             __PRINTS( "CClockMainContainer::ComponentControl - Exit" );
       
   903             
       
   904             // Return the new alarm button.
       
   905             return iNewAlarmButton;
       
   906             }            
       
   907             
       
   908         case 2:
       
   909             {
   816 			__PRINTS( "CClockMainContainer::ComponentControl - Exit" );
   910 			__PRINTS( "CClockMainContainer::ComponentControl - Exit" );
   817 			
   911 			
   818             // Return the listbox.
   912             // Return the listbox.
   819             return iListBox;
   913             return iListBox;
   820             }
   914             }
   861     // If skinnable clock is present, let it handle the resource change.
   955     // If skinnable clock is present, let it handle the resource change.
   862     if( iSkinnableClock )
   956     if( iSkinnableClock )
   863         {
   957         {
   864         iSkinnableClock->HandleResourceChange( aType );
   958         iSkinnableClock->HandleResourceChange( aType );
   865         }
   959         }
       
   960 
       
   961     // Allow the listbox to handle the resource change.
       
   962     if( iNewAlarmButton )
       
   963         {
       
   964         iNewAlarmButton->HandleResourceChange( aType );
       
   965         }
       
   966 
   866     // Allow the listbox to handle the resource change.
   967     // Allow the listbox to handle the resource change.
   867     if( iListBox )
   968     if( iListBox )
   868         {
   969         {
   869         iListBox->HandleResourceChange( aType );
   970         iListBox->HandleResourceChange( aType );
   870         }
   971         }
  1200     iListBox->View()->SetListEmptyTextL( _L("") );
  1301     iListBox->View()->SetListEmptyTextL( _L("") );
  1201     iListBox->ActivateL();
  1302     iListBox->ActivateL();
  1202 	
  1303 	
  1203     // Cleanup.
  1304     // Cleanup.
  1204 	CleanupStack::Pop( iconArray );
  1305 	CleanupStack::Pop( iconArray );
  1205 	
  1306 
       
  1307     // construct the "New Alarm" button
       
  1308     iNewAlarmButton = CAknButton::NewL( NULL, NULL, NULL, NULL,
       
  1309             iAlarmArray->NewAlarmText()->Des(),iAlarmArray->NewAlarmText()->Des(), 0, 0 );
       
  1310     iNewAlarmButton->SetParent( this );
       
  1311     iNewAlarmButton->SetContainerWindowL( *this );
       
  1312     //TAknLayoutRect newAlarmButtonRect;
       
  1313     // Get the skinnable clock rect.
       
  1314     //newAlarmButtonRect.LayoutRect( listRect.Rect(),
       
  1315     //        AknLayoutScalable_Apps::main_clock2_btn_pane( layoutOrientation  ).LayoutLine() );
       
  1316     
       
  1317     //iNewAlarmButton->SetRect( newAlarmButtonRect.Rect() );
       
  1318     SetCorrectRectForNewAlarmButton();
       
  1319     iNewAlarmButton->SetObserver( this );
       
  1320     iNewAlarmButton->ActivateL();
  1206     // Add the icon for DST indicator.
  1321     // Add the icon for DST indicator.
  1207     AknsUtils::CreateColorIconL( AknsUtils::SkinInstance(),
  1322     AknsUtils::CreateColorIconL( AknsUtils::SkinInstance(),
  1208                                  KAknsIIDQgnIndiDstAdd,
  1323                                  KAknsIIDQgnIndiDstAdd,
  1209                                  KAknsIIDQsnIconColors,
  1324                                  KAknsIIDQsnIconColors,
  1210                                  EAknsCIQsnIconColorsCG13,
  1325                                  EAknsCIQsnIconColorsCG13,
  1477             errorVal = clkSrvIf.IsAutoTimeUpdateOn( timeUpdateOn );
  1592             errorVal = clkSrvIf.IsAutoTimeUpdateOn( timeUpdateOn );
  1478             }
  1593             }
  1479         return timeUpdateOn;
  1594         return timeUpdateOn;
  1480 }
  1595 }
  1481 
  1596 
       
  1597 void CClockMainContainer::HandleControlEventL( CCoeControl* aControl,
       
  1598             TCoeEvent aEventType )
       
  1599     {
       
  1600     if ( aControl == iNewAlarmButton && aEventType == MCoeControlObserver::EEventStateChanged )
       
  1601         {
       
  1602         iView->HandleCommandL( EClockNewAlarm );
       
  1603         }
       
  1604     }
       
  1605 
       
  1606 void CClockMainContainer::SetCorrectRectForNewAlarmButton()
       
  1607     {
       
  1608     if( iNewAlarmButton )
       
  1609         {
       
  1610         TRect paneRect = this->Rect();
       
  1611         TAknLayoutRect newAlarmButtonRect;
       
  1612         TAknLayoutRect mainRect;
       
  1613         TInt displayOrientation( Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0 );
       
  1614         // Get the layout for the main rect.
       
  1615         mainRect.LayoutRect( paneRect,
       
  1616                 AknLayoutScalable_Apps::main_clock2_pane().LayoutLine() );
       
  1617         if( displayOrientation )
       
  1618             {
       
  1619             // landscape
       
  1620             TInt alarmCount( 0 );
       
  1621             if( iListBox )
       
  1622                 {
       
  1623                 alarmCount = iListBox->Model()->ItemTextArray()->MdcaCount();
       
  1624                 }
       
  1625             if( alarmCount > 0 )
       
  1626                 {
       
  1627             if( iListBox )
       
  1628                 {
       
  1629                 iListBox->MakeVisible( ETrue );
       
  1630                 }
       
  1631                 // landscape if not empty alarm list
       
  1632                 newAlarmButtonRect.LayoutRect( mainRect.Rect(),
       
  1633                         AknLayoutScalable_Apps::main_clock2_btn_pane( displayOrientation ).LayoutLine() );
       
  1634                 }
       
  1635             else
       
  1636                 {
       
  1637                 // landscape if empty alarm list
       
  1638                 if( iListBox )
       
  1639                     {
       
  1640                     iListBox->MakeVisible( EFalse );
       
  1641                     }
       
  1642                 newAlarmButtonRect.LayoutRect( mainRect.Rect(),
       
  1643                         AknLayoutScalable_Apps::main_clock2_btn_pane_cp01( displayOrientation ).LayoutLine() );
       
  1644                 }
       
  1645             }
       
  1646         else
       
  1647             {
       
  1648             // portrait
       
  1649             if( iListBox )
       
  1650                 {
       
  1651                 iListBox->MakeVisible( ETrue );
       
  1652                 }
       
  1653             newAlarmButtonRect.LayoutRect( mainRect.Rect(),
       
  1654                     AknLayoutScalable_Apps::main_clock2_btn_pane( displayOrientation ).LayoutLine() );
       
  1655             }
       
  1656         iNewAlarmButton->SetRect( newAlarmButtonRect.Rect() );
       
  1657         }
       
  1658 
       
  1659     }
       
  1660 
       
  1661 void CClockMainContainer::SwitchClockTypeL()
       
  1662     {
       
  1663     TRect skinClockRect = iSkinnableClock->Rect();
       
  1664     delete iSkinnableClock;
       
  1665     iSkinnableClock = NULL;
       
  1666     // Construct the skinnable clock.
       
  1667     iSkinnableClock = CAknSkinnableClock::NewL( this, ETrue, EFalse );
       
  1668     // Set the size of the clock.
       
  1669     iSkinnableClock->SetExtent( skinClockRect.iTl, skinClockRect.Size() );
       
  1670     iSkinnableClock->ActivateL();
       
  1671     iSkinnableClock->DrawDeferred();
       
  1672     }
  1482 // End of file
  1673 // End of file