clock2/clockui/uilayer/clockmainview/src/clockmaincontainer.cpp
branchRCL_3
changeset 36 9c5b1510919f
parent 30 d68a4b5d5885
child 60 96907930389d
equal deleted inserted replaced
30:d68a4b5d5885 36:9c5b1510919f
    75 _LIT( KIconFileName, "\\resource\\apps\\clockapp.mif" );
    75 _LIT( KIconFileName, "\\resource\\apps\\clockapp.mif" );
    76 _LIT( KPlusGMT, " \x202A+" );
    76 _LIT( KPlusGMT, " \x202A+" );
    77 _LIT( KMinusGMT, " \x202A" );
    77 _LIT( KMinusGMT, " \x202A" );
    78 _LIT( KPDF, " \x202C" );
    78 _LIT( KPDF, " \x202C" );
    79 _LIT( KZero, "0" );
    79 _LIT( KZero, "0" );
       
    80 _LIT( KSpace, " " );
    80 
    81 
    81 // ---------------------------------------------------------
    82 // ---------------------------------------------------------
    82 // CClockMainContainer::NewL
    83 // CClockMainContainer::NewL
    83 // rest of the details are commented in the header
    84 // rest of the details are commented in the header
    84 // ---------------------------------------------------------
    85 // ---------------------------------------------------------
   388 		__PRINTS( "CClockMainContainer::HandlePointerEventL - Exit" );
   389 		__PRINTS( "CClockMainContainer::HandlePointerEventL - Exit" );
   389 		
   390 		
   390         return;
   391         return;
   391         }
   392         }
   392     
   393     
       
   394     // to highlight the item in alarm list after long tapping
       
   395     //( when new alarm button is focused)
       
   396     if( iListBox && iListBox->Rect().Contains( aPointerEvent.iPosition ) &&
       
   397             aPointerEvent.iType == TPointerEvent::EButton1Down &&
       
   398             !iListBox->IsFocused() && iListBox->IsVisible() )
       
   399         {
       
   400         iListBox->View()->ItemDrawer()->ClearFlags( CListItemDrawer::EDisableHighlight );
       
   401         }
       
   402     
   393     // to get the vibes let's handle skinnable clock as a special case
   403     // to get the vibes let's handle skinnable clock as a special case
   394     // no need to to delegate pointer events to it
   404     // no need to to delegate pointer events to it
   395     if( iSkinnableClock && iSkinnableClock->Rect().Contains( aPointerEvent.iPosition ) )
   405     if( iSkinnableClock && iSkinnableClock->Rect().Contains( aPointerEvent.iPosition ) )
   396         {
   406         {
   397         if( aPointerEvent.iType == TPointerEvent::EButton1Down  )
   407         if( aPointerEvent.iType == TPointerEvent::EButton1Down  )
   403                 {
   413                 {
   404                 iView->GiveVibes();
   414                 iView->GiveVibes();
   405                 iView->HandleCommandL( EClockSwitchClockType ); 
   415                 iView->HandleCommandL( EClockSwitchClockType ); 
   406                 iPreviousClockTypeSwitch.HomeTime();
   416                 iPreviousClockTypeSwitch.HomeTime();
   407                 }   
   417                 }   
       
   418             }
       
   419         else
       
   420             {
       
   421             CCoeControl::HandlePointerEventL( aPointerEvent );
   408             }
   422             }
   409         } 
   423         } 
   410     else
   424     else
   411         {
   425         {
   412         CCoeControl::HandlePointerEventL( aPointerEvent );
   426         CCoeControl::HandlePointerEventL( aPointerEvent );
   469 	__PRINTS( "CClockMainContainer::RemoveAlarmL - Entry" );
   483 	__PRINTS( "CClockMainContainer::RemoveAlarmL - Entry" );
   470 	
   484 	
   471     // Reinitialize the alarm list.
   485     // Reinitialize the alarm list.
   472     iAlarmArray->InitIdList();
   486     iAlarmArray->InitIdList();
   473     TInt count = iListBox->Model()->ItemTextArray()->MdcaCount();
   487     TInt count = iListBox->Model()->ItemTextArray()->MdcaCount();
   474     
       
   475     //SetCorrectRectForNewAlarmButton();
       
   476     
   488     
   477     // if only one item
   489     // if only one item
   478     if( ( KZeroAlarms == aIndex ) && ( aIndex == count ) )
   490     if( ( KZeroAlarms == aIndex ) && ( aIndex == count ) )
   479         {
   491         {
   480         iListBox->SetCurrentItemIndex( KZeroAlarms );
   492         iListBox->SetCurrentItemIndex( KZeroAlarms );
  1304     // Cleanup.
  1316     // Cleanup.
  1305 	CleanupStack::Pop( iconArray );
  1317 	CleanupStack::Pop( iconArray );
  1306 
  1318 
  1307     // construct the "New Alarm" button
  1319     // construct the "New Alarm" button
  1308     iNewAlarmButton = CAknButton::NewL( NULL, NULL, NULL, NULL,
  1320     iNewAlarmButton = CAknButton::NewL( NULL, NULL, NULL, NULL,
  1309             iAlarmArray->NewAlarmText()->Des(),iAlarmArray->NewAlarmText()->Des(), 0, 0 );
  1321             iAlarmArray->NewAlarmText()->Des(), KNullDesC, 0, 0 );
  1310     iNewAlarmButton->SetParent( this );
  1322     iNewAlarmButton->SetParent( this );
  1311     iNewAlarmButton->SetContainerWindowL( *this );
  1323     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();
  1324     SetCorrectRectForNewAlarmButton();
  1319     iNewAlarmButton->SetObserver( this );
  1325     iNewAlarmButton->SetObserver( this );
  1320     iNewAlarmButton->ActivateL();
  1326     iNewAlarmButton->ActivateL();
  1321     // Add the icon for DST indicator.
  1327     // Add the icon for DST indicator.
  1322     AknsUtils::CreateColorIconL( AknsUtils::SkinInstance(),
  1328     AknsUtils::CreateColorIconL( AknsUtils::SkinInstance(),
  1393     TAknLayoutRect parentRect;
  1399     TAknLayoutRect parentRect;
  1394     parentRect.LayoutRect( Rect(), AknLayoutScalable_Apps::main_clock2_pane().LayoutLine() );
  1400     parentRect.LayoutRect( Rect(), AknLayoutScalable_Apps::main_clock2_pane().LayoutLine() );
  1395         
  1401         
  1396     TRect mainClockPane( parentRect.Rect() );
  1402     TRect mainClockPane( parentRect.Rect() );
  1397    
  1403    
  1398     // Get the layout for the day string.
  1404     if( Layout_Meta_Data::IsLandscapeOrientation() )
  1399     layoutText.LayoutText( mainClockPane, AknLayoutScalable_Apps::main_clock2_pane_t1( displayOrientation ).LayoutLine() );
  1405         {
  1400 
  1406         // main_clock2_pane_cp01_t1 Day + date
  1401     TPtr dayStringPtr = iDayNameString->Des();
  1407        HBufC* dayAndDateString = HBufC::NewLC( iDayNameString->Length() + iDateString->Length() + 1 );
  1402     // Day long format.
  1408        TPtr dayAndDateStringPtr = dayAndDateString->Des();
  1403     layoutText.DrawText( aWindowGc, *iDayNameString, ETrue, cachedColor );
  1409        dayAndDateStringPtr.Append( *iDayNameString );
  1404     
  1410        dayAndDateStringPtr.Append( KSpace );
  1405     // Get the layout for the datestring.
  1411        TPtr dateStringPtr = iDateString->Des();
  1406     layoutText.LayoutText( mainClockPane, AknLayoutScalable_Apps::main_clock2_pane_t2( displayOrientation ).LayoutLine() );
  1412        AknTextUtils::DisplayTextLanguageSpecificNumberConversion( dateStringPtr );
  1407 
  1413        dayAndDateStringPtr.Append( *iDateString );
  1408     TPtr dateStringPtr = iDateString->Des();
  1414        
  1409     // For mirrored languages.
  1415        layoutText.LayoutText( mainClockPane, AknLayoutScalable_Apps::main_clock2_pane_cp01_t1( displayOrientation ).LayoutLine() );
  1410     AknTextUtils::DisplayTextLanguageSpecificNumberConversion( dateStringPtr );
  1416        layoutText.DrawText( aWindowGc, *dayAndDateString , ETrue, cachedColor );
  1411     // Date long format
  1417        
  1412     layoutText.DrawText( aWindowGc, *iDateString, ETrue, cachedColor );
  1418        CleanupStack::PopAndDestroy( dayAndDateString );
  1413     
  1419        dayAndDateString = NULL;
  1414     // Get the layout for the timezone string.
  1420        
  1415     layoutText.LayoutText( mainClockPane, AknLayoutScalable_Apps::main_clock2_pane_t3( Layout_Meta_Data::IsLandscapeOrientation() ).LayoutLine() );
  1421        // main_clock2_pane_cp01_t3 zone + country
  1416 
  1422        HBufC* timeZoneAndCountryString = HBufC::NewLC( iTimeZoneString->Length() + iLocationString->Length() + 1 );
  1417     TPtr timeZonePtr = iTimeZoneString->Des();
  1423        TPtr timeZoneAndCountryStringPtr = timeZoneAndCountryString->Des();
  1418     // This is for mirrored languages.
  1424        TPtr timeZoneStringPtr = iTimeZoneString->Des();
  1419     AknTextUtils::DisplayTextLanguageSpecificNumberConversion( timeZonePtr );
  1425        AknTextUtils::DisplayTextLanguageSpecificNumberConversion( timeZoneStringPtr );
  1420     // The timezone string.
  1426        timeZoneAndCountryStringPtr.Append( *iTimeZoneString );
  1421     layoutText.DrawText( aWindowGc, *iTimeZoneString, ETrue, cachedColor );
  1427        timeZoneAndCountryStringPtr.Append( KSpace );
  1422     
  1428        timeZoneAndCountryStringPtr.Append( *iLocationString );
  1423     // Get the layout for the country string.
  1429        
  1424     TAknTextComponentLayout labelLayout;
  1430        layoutText.LayoutText( mainClockPane, AknLayoutScalable_Apps::main_clock2_pane_cp01_t3( displayOrientation ).LayoutLine() );
  1425     labelLayout = AknLayoutScalable_Apps::main_clock2_pane_t4( Layout_Meta_Data::IsLandscapeOrientation() );
  1431        layoutText.DrawText( aWindowGc, *timeZoneAndCountryString, ETrue, cachedColor );
  1426     AknLayoutUtils::LayoutLabel( iLocationLabel, parentRect.Rect(), labelLayout.LayoutLine() );
  1432        /*
  1427     
  1433        TAknTextComponentLayout labelLayout;
  1428     // Set the label for the text and start marqueeing.
  1434        labelLayout = AknLayoutScalable_Apps::main_clock2_pane_cp01_t3( Layout_Meta_Data::IsLandscapeOrientation() );
  1429     iLocationLabel->SetLabelTextL( *iLocationString );
  1435        AknLayoutUtils::LayoutLabel( iLocationLabel, parentRect.Rect(), labelLayout.LayoutLine() );
  1430     iLocationLabel->StartMarquee();
  1436        
  1431     iLocationLabel->RedrawRect( iLocationLabel->Rect() );
  1437        // Set the label for the text and start marqueeing.
  1432 
  1438        iLocationLabel->SetLabelTextL( *timeZoneAndCountryString );
  1433 	// We display empty text only if there are no alarms set.
  1439        TGulAlignment alignment;
  1434 	// if( !iAlarmArray->MdcaCount() )
  1440        alignment.SetHAlignment( EHCenter );
  1435 		// {
  1441        iLocationLabel->SetAlignment( alignment );
  1436 		// Set the listbox layout.
  1442        iLocationLabel->StartMarquee();
  1437 		// TAknLayoutRect listRect;
  1443        iLocationLabel->RedrawRect( iLocationLabel->Rect() );
  1438 		// Get the main clock rect.
  1444        */
  1439 		// listRect.LayoutRect( mainClockPane, AknLayoutScalable_Apps::listscroll_gen_pane_cp06( Layout_Meta_Data::IsLandscapeOrientation() ).LayoutLine() );
  1445        CleanupStack::PopAndDestroy( timeZoneAndCountryString );
  1440 		
  1446        timeZoneAndCountryString  = NULL;
  1441 		// Get the rect for the empty text.
  1447         }
  1442 		// layoutText.LayoutText( listRect.Rect(), AknLayoutScalable_Apps::listscroll_gen_pane_cp06_t1( Layout_Meta_Data::IsLandscapeOrientation() ).LayoutLine() );
  1448     else
  1443 		// Draw the text.
  1449         {
  1444 		// layoutText.DrawText( aWindowGc, *iNoAlarmsText, ETrue, cachedColor );
  1450         // Get the layout for the day string.
  1445 		//}
  1451         layoutText.LayoutText( mainClockPane, AknLayoutScalable_Apps::main_clock2_pane_t1( displayOrientation ).LayoutLine() );
  1446     
  1452     
       
  1453         TPtr dayStringPtr = iDayNameString->Des();
       
  1454         // Day long format.
       
  1455         layoutText.DrawText( aWindowGc, *iDayNameString, ETrue, cachedColor );
       
  1456         
       
  1457         // Get the layout for the datestring.
       
  1458         layoutText.LayoutText( mainClockPane, AknLayoutScalable_Apps::main_clock2_pane_t2( displayOrientation ).LayoutLine() );
       
  1459     
       
  1460         TPtr dateStringPtr = iDateString->Des();
       
  1461         // For mirrored languages.
       
  1462         AknTextUtils::DisplayTextLanguageSpecificNumberConversion( dateStringPtr );
       
  1463         // Date long format
       
  1464         layoutText.DrawText( aWindowGc, *iDateString, ETrue, cachedColor );
       
  1465         
       
  1466         // Get the layout for the timezone string.
       
  1467         layoutText.LayoutText( mainClockPane, AknLayoutScalable_Apps::main_clock2_pane_t3( Layout_Meta_Data::IsLandscapeOrientation() ).LayoutLine() );
       
  1468     
       
  1469         TPtr timeZonePtr = iTimeZoneString->Des();
       
  1470         // This is for mirrored languages.
       
  1471         AknTextUtils::DisplayTextLanguageSpecificNumberConversion( timeZonePtr );
       
  1472         // The timezone string.
       
  1473         layoutText.DrawText( aWindowGc, *iTimeZoneString, ETrue, cachedColor );
       
  1474         
       
  1475         // Get the layout for the country string.
       
  1476         TAknTextComponentLayout labelLayout;
       
  1477         labelLayout = AknLayoutScalable_Apps::main_clock2_pane_t4( Layout_Meta_Data::IsLandscapeOrientation() );
       
  1478         AknLayoutUtils::LayoutLabel( iLocationLabel, parentRect.Rect(), labelLayout.LayoutLine() );
       
  1479         
       
  1480         // Set the label for the text and start marqueeing.
       
  1481         iLocationLabel->SetLabelTextL( *iLocationString );
       
  1482         iLocationLabel->StartMarquee();
       
  1483         iLocationLabel->RedrawRect( iLocationLabel->Rect() );
       
  1484         }
  1447 	__PRINTS( "CClockMainContainer::DrawMainViewText - Exit" );
  1485 	__PRINTS( "CClockMainContainer::DrawMainViewText - Exit" );
  1448     }
  1486     }
  1449 
  1487 
  1450 // ---------------------------------------------------------
  1488 // ---------------------------------------------------------
  1451 // CClockMainContainer::IsDstOnL
  1489 // CClockMainContainer::IsDstOnL
  1595 }
  1633 }
  1596 
  1634 
  1597 void CClockMainContainer::HandleControlEventL( CCoeControl* aControl,
  1635 void CClockMainContainer::HandleControlEventL( CCoeControl* aControl,
  1598             TCoeEvent aEventType )
  1636             TCoeEvent aEventType )
  1599     {
  1637     {
  1600     if ( aControl == iNewAlarmButton && aEventType == MCoeControlObserver::EEventStateChanged )
  1638     if ( aControl == iNewAlarmButton && aEventType == MCoeControlObserver::EEventStateChanged 
       
  1639             && iView && !iView->IsAlarmEditorOpen() )
  1601         {
  1640         {
  1602         iView->HandleCommandL( EClockNewAlarm );
  1641         iView->HandleCommandL( EClockNewAlarm );
  1603         }
  1642         }
  1604     }
  1643     }
  1605 
  1644