idlehomescreen/xmluirendering/renderingplugins/xnclockfactory/src/xnclockadapter.cpp
branchRCL_3
changeset 23 7be2816dbabd
parent 12 9674c1a575e9
equal deleted inserted replaced
19:79311d856354 23:7be2816dbabd
     9 * Initial Contributors:
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:  Implementation wrapper for CAknSkinnableClock
    14 * Description:  Clock rendering plugin
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 // SYSTEM INCLUDE FILES
    18 // System includes
    19 #include <e32base.h>
    19 #include <e32base.h>
    20 #include <e32const.h>
    20 #include <e32const.h>
    21 #include <AknLayoutFont.h>
    21 #include <AknLayoutFont.h>
    22 #include <AknsUtils.h>
    22 #include <AknsUtils.h>
    23 
    23 
    24 // USER INCLUDE FILES
    24 // User includes
    25 #include "xndomproperty.h"
    25 #include "xndomproperty.h"
    26 #include "xndomlist.h"
    26 #include "xndomlist.h"
    27 #include "xnproperty.h"
    27 #include "xnproperty.h"
    28 #include "xntype.h"
    28 #include "xntype.h"
    29 #include "xnuienginepluginif.h"
    29 #include "xnuienginepluginif.h"
    31 #include "xncontroladapter.h"
    31 #include "xncontroladapter.h"
    32 #include "xnclockcontrol.h"
    32 #include "xnclockcontrol.h"
    33 #include "xnclockadapter.h"
    33 #include "xnclockadapter.h"
    34 #include "c_xnutils.h"
    34 #include "c_xnutils.h"
    35 
    35 
    36 // CONSTANTS
    36 // Constants
    37 _LIT8( KDateInformation, "Clock/DateInformation" );
    37 _LIT8( KDateInformation, "Clock/DateInformation" );
    38 _LIT8( KDayInformation, "Clock/DayInformation" );
    38 _LIT8( KDayInformation, "Clock/DayInformation" );
    39 
    39 
    40 _LIT( KDigitalFont, "EAknLogicalFontSecondaryFont" );
    40 _LIT( KDigitalFont, "EAknLogicalFontSecondaryFont" );
    41 _LIT( KAmPmFont, "EAknLogicalFontSecondaryFont" );
    41 _LIT( KAmPmFont, "EAknLogicalFontSecondaryFont" );
   115 // -----------------------------------------------------------------------------
   115 // -----------------------------------------------------------------------------
   116 //
   116 //
   117 CXnClockAdapter::~CXnClockAdapter()
   117 CXnClockAdapter::~CXnClockAdapter()
   118     {    
   118     {    
   119     iCoeEnv->RemoveMessageMonitorObserver( *this );    
   119     iCoeEnv->RemoveMessageMonitorObserver( *this );    
   120     
   120 
       
   121     delete iLightObserver;    
   121     delete iClockControl;
   122     delete iClockControl;
   122     }
   123     }
   123 
   124 
   124 // -----------------------------------------------------------------------------
   125 // -----------------------------------------------------------------------------
   125 // CXnClockAdapter::ConstructL
   126 // CXnClockAdapter::ConstructL
   126 // Symbian 2nd phase constructor can leave.
   127 // Symbian 2nd phase constructor can leave.
   127 // -----------------------------------------------------------------------------
   128 // -----------------------------------------------------------------------------
   128 //
   129 //
   129 void CXnClockAdapter::ConstructL()
   130 void CXnClockAdapter::ConstructL()
   130     {
   131     {          
   131     CXnControlAdapter::ConstructL( iNode );     
   132     CXnControlAdapter::ConstructL( iNode );   
   132             
   133     
       
   134     iForeground = iAvkonAppUi->IsForeground();
       
   135     
       
   136     iLightObserver = CHWRMLight::NewL( this );
       
   137     
   133     RPointerArray< CXnNodePluginIf > children( iNode.ChildrenL() );
   138     RPointerArray< CXnNodePluginIf > children( iNode.ChildrenL() );
   134     CleanupClosePushL( children );
   139     CleanupClosePushL( children );
   135     
   140     
   136     for( TInt i = 0; i < children.Count(); i++ )
   141     for( TInt i = 0; i < children.Count(); i++ )
   137         {
   142         {
   166     iCoeEnv->AddMessageMonitorObserverL( *this );
   171     iCoeEnv->AddMessageMonitorObserverL( *this );
   167 	}
   172 	}
   168  
   173  
   169 // -----------------------------------------------------------------------------
   174 // -----------------------------------------------------------------------------
   170 // CXnClockAdapter::DoHandlePropertyChangeL
   175 // CXnClockAdapter::DoHandlePropertyChangeL
       
   176 //
   171 // -----------------------------------------------------------------------------
   177 // -----------------------------------------------------------------------------
   172 //
   178 //
   173 void CXnClockAdapter::DoHandlePropertyChangeL( CXnProperty* aProperty )
   179 void CXnClockAdapter::DoHandlePropertyChangeL( CXnProperty* aProperty )
   174     {        
   180     {        
   175     if( aProperty )
   181     if( aProperty )
   237 //        
   243 //        
   238 void CXnClockAdapter::MakeVisible( TBool aVisible )
   244 void CXnClockAdapter::MakeVisible( TBool aVisible )
   239     {
   245     {
   240     TBool visible( IsVisible() );
   246     TBool visible( IsVisible() );
   241     
   247     
   242     if ( aVisible != visible )
   248     if ( visible != aVisible )
   243         {
   249         {
   244         CCoeControl::MakeVisible( aVisible );
   250         CCoeControl::MakeVisible( aVisible );
   245 
   251         
   246         if ( !aVisible )
   252         if ( aVisible )
   247             {
   253             {
   248             iClockControl->StopTimer();
   254             // Start clock ensures UI state
   249             }
   255             StartClock();
       
   256             }
       
   257         else
       
   258             {
       
   259             StopClock();        
       
   260             }    
   250         }
   261         }
   251     }
   262     }
   252 
   263 
   253 // -----------------------------------------------------------------------------
   264 // -----------------------------------------------------------------------------
   254 // CXnClockAdapter::MonitorWsMessage
   265 // CXnClockAdapter::MonitorWsMessage
   268     else if( type == KAknFullOrPartialForegroundLost )        
   279     else if( type == KAknFullOrPartialForegroundLost )        
   269         {
   280         {
   270         iForeground = EFalse;        
   281         iForeground = EFalse;        
   271         }
   282         }
   272 
   283 
   273     if( foreground != iForeground && IsVisible() )            
   284     if( foreground != iForeground )            
   274         {
   285         {
   275         if( iForeground )
   286         if( iForeground )
   276             {
   287             {   
   277             UpdateDisplay(); // starts timer after update
   288             UpdateDisplay();
   278             iClockControl->StartTimer();
   289             
       
   290             // Start clock ensures UI state
       
   291             StartClock();
   279             }
   292             }
   280         else
   293         else
   281             {
   294             {
   282             iClockControl->StopTimer();
   295             StopClock();
   283             }            
   296             }            
   284         }
   297         }
   285     }
   298     }
       
   299 
       
   300 // -----------------------------------------------------------------------------
       
   301 // CXnClockAdapter::LightStatusChanged
       
   302 // 
       
   303 // -----------------------------------------------------------------------------
       
   304 //    
       
   305 void CXnClockAdapter::LightStatusChanged( TInt aTarget, 
       
   306     CHWRMLight::TLightStatus aStatus )
       
   307     {
       
   308     if ( aTarget == CHWRMLight::EPrimaryDisplay )
       
   309         {
       
   310         if ( aStatus == CHWRMLight::ELightOn )
       
   311             {
       
   312             iLightsOn = ETrue;
       
   313             
       
   314             if ( iForeground )
       
   315                 {
       
   316                 UpdateDisplay();
       
   317                 }
       
   318                         
       
   319             // Start clock ensures UI state
       
   320             StartClock();
       
   321             }
       
   322         else if ( aStatus == CHWRMLight::ELightOff )
       
   323             {
       
   324             iLightsOn = EFalse;
       
   325         
       
   326             StopClock();
       
   327             }        
       
   328         }
       
   329     }
       
   330 
   286 
   331 
   287 // -----------------------------------------------------------------------------
   332 // -----------------------------------------------------------------------------
   288 // CXnClockAdapter::FontL
   333 // CXnClockAdapter::FontL
   289 // 
   334 // 
   290 // -----------------------------------------------------------------------------
   335 // -----------------------------------------------------------------------------
   551     iColorSet = EFalse;
   596     iColorSet = EFalse;
   552     
   597     
   553     CXnControlAdapter::SizeChanged();    
   598     CXnControlAdapter::SizeChanged();    
   554     }
   599     }
   555 
   600 
       
   601 // -----------------------------------------------------------------------------
       
   602 // CXnClockAdapter::StartClock
       
   603 // 
       
   604 // -----------------------------------------------------------------------------
       
   605 // 
       
   606 void CXnClockAdapter::StartClock()
       
   607     {    
       
   608     if ( iClockControl )
       
   609         {        
       
   610         if ( iForeground && iLightsOn && IsVisible() )
       
   611             {
       
   612             iClockControl->StartTimer();
       
   613             }
       
   614         else
       
   615             {
       
   616             StopClock();
       
   617             }    
       
   618         }
       
   619     }
       
   620 
       
   621 // -----------------------------------------------------------------------------
       
   622 // CXnClockAdapter::StopClock
       
   623 // 
       
   624 // -----------------------------------------------------------------------------
       
   625 // 
       
   626 void CXnClockAdapter::StopClock()
       
   627     {
       
   628     if ( iClockControl )
       
   629         {
       
   630         iClockControl->StopTimer();
       
   631         }    
       
   632     }
       
   633 
   556 // End of file
   634 // End of file