idlehomescreen/xmluirendering/renderingplugins/xnclockfactory/src/xnclockadapter.cpp
--- a/idlehomescreen/xmluirendering/renderingplugins/xnclockfactory/src/xnclockadapter.cpp Tue Apr 27 16:26:12 2010 +0300
+++ b/idlehomescreen/xmluirendering/renderingplugins/xnclockfactory/src/xnclockadapter.cpp Tue May 11 16:02:39 2010 +0300
@@ -11,17 +11,17 @@
*
* Contributors:
*
-* Description: Implementation wrapper for CAknSkinnableClock
+* Description: Clock rendering plugin
*
*/
-// SYSTEM INCLUDE FILES
+// System includes
#include <e32base.h>
#include <e32const.h>
#include <AknLayoutFont.h>
#include <AknsUtils.h>
-// USER INCLUDE FILES
+// User includes
#include "xndomproperty.h"
#include "xndomlist.h"
#include "xnproperty.h"
@@ -33,7 +33,7 @@
#include "xnclockadapter.h"
#include "c_xnutils.h"
-// CONSTANTS
+// Constants
_LIT8( KDateInformation, "Clock/DateInformation" );
_LIT8( KDayInformation, "Clock/DayInformation" );
@@ -117,7 +117,8 @@
CXnClockAdapter::~CXnClockAdapter()
{
iCoeEnv->RemoveMessageMonitorObserver( *this );
-
+
+ delete iLightObserver;
delete iClockControl;
}
@@ -127,9 +128,13 @@
// -----------------------------------------------------------------------------
//
void CXnClockAdapter::ConstructL()
- {
- CXnControlAdapter::ConstructL( iNode );
-
+ {
+ CXnControlAdapter::ConstructL( iNode );
+
+ iForeground = iAvkonAppUi->IsForeground();
+
+ iLightObserver = CHWRMLight::NewL( this );
+
RPointerArray< CXnNodePluginIf > children( iNode.ChildrenL() );
CleanupClosePushL( children );
@@ -168,6 +173,7 @@
// -----------------------------------------------------------------------------
// CXnClockAdapter::DoHandlePropertyChangeL
+//
// -----------------------------------------------------------------------------
//
void CXnClockAdapter::DoHandlePropertyChangeL( CXnProperty* aProperty )
@@ -239,14 +245,19 @@
{
TBool visible( IsVisible() );
- if ( aVisible != visible )
+ if ( visible != aVisible )
{
CCoeControl::MakeVisible( aVisible );
-
- if ( !aVisible )
+
+ if ( aVisible )
{
- iClockControl->StopTimer();
+ // Start clock ensures UI state
+ StartClock();
}
+ else
+ {
+ StopClock();
+ }
}
}
@@ -270,21 +281,55 @@
iForeground = EFalse;
}
- if( foreground != iForeground && IsVisible() )
+ if( foreground != iForeground )
{
if( iForeground )
- {
- UpdateDisplay(); // starts timer after update
- iClockControl->StartTimer();
+ {
+ UpdateDisplay();
+
+ // Start clock ensures UI state
+ StartClock();
}
else
{
- iClockControl->StopTimer();
+ StopClock();
}
}
}
// -----------------------------------------------------------------------------
+// CXnClockAdapter::LightStatusChanged
+//
+// -----------------------------------------------------------------------------
+//
+void CXnClockAdapter::LightStatusChanged( TInt aTarget,
+ CHWRMLight::TLightStatus aStatus )
+ {
+ if ( aTarget == CHWRMLight::EPrimaryDisplay )
+ {
+ if ( aStatus == CHWRMLight::ELightOn )
+ {
+ iLightsOn = ETrue;
+
+ if ( iForeground )
+ {
+ UpdateDisplay();
+ }
+
+ // Start clock ensures UI state
+ StartClock();
+ }
+ else if ( aStatus == CHWRMLight::ELightOff )
+ {
+ iLightsOn = EFalse;
+
+ StopClock();
+ }
+ }
+ }
+
+
+// -----------------------------------------------------------------------------
// CXnClockAdapter::FontL
//
// -----------------------------------------------------------------------------
@@ -553,4 +598,37 @@
CXnControlAdapter::SizeChanged();
}
+// -----------------------------------------------------------------------------
+// CXnClockAdapter::StartClock
+//
+// -----------------------------------------------------------------------------
+//
+void CXnClockAdapter::StartClock()
+ {
+ if ( iClockControl )
+ {
+ if ( iForeground && iLightsOn && IsVisible() )
+ {
+ iClockControl->StartTimer();
+ }
+ else
+ {
+ StopClock();
+ }
+ }
+ }
+
+// -----------------------------------------------------------------------------
+// CXnClockAdapter::StopClock
+//
+// -----------------------------------------------------------------------------
+//
+void CXnClockAdapter::StopClock()
+ {
+ if ( iClockControl )
+ {
+ iClockControl->StopTimer();
+ }
+ }
+
// End of file