idlehomescreen/xmluirendering/renderingplugins/xnclockfactory/src/xnclockadapter.cpp
branchRCL_3
changeset 102 ba63c83f4716
parent 93 b01126ce0bec
equal deleted inserted replaced
93:b01126ce0bec 102:ba63c83f4716
    29 #include "xnuienginepluginif.h"
    29 #include "xnuienginepluginif.h"
    30 #include "xnnodepluginif.h"
    30 #include "xnnodepluginif.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 "xndatecontrol.h"
       
    35 #include "c_xnutils.h"
    34 #include "c_xnutils.h"
    36 
    35 
    37 // Constants
    36 // Constants
    38 _LIT8( KDisplay, "display" );
    37 _LIT8( KDateInformation, "Clock/DateInformation" );
    39 _LIT8( KNone, "none" );
    38 _LIT8( KDayInformation, "Clock/DayInformation" );
    40 _LIT8( KBlock, "block" );
    39 
    41 _LIT( KLogicalSecondaryFont, "EAknLogicalFontSecondaryFont" );
    40 _LIT( KDigitalFont, "EAknLogicalFontSecondaryFont" );
       
    41 _LIT( KAmPmFont, "EAknLogicalFontSecondaryFont" );
       
    42 _LIT( KDateFont, "EAknLogicalFontSecondaryFont" );
    42 
    43 
    43 // ============================ LOCAL FUNCTIONS ===============================    
    44 // ============================ LOCAL FUNCTIONS ===============================    
    44 
    45 
    45 // -----------------------------------------------------------------------------
    46 // -----------------------------------------------------------------------------
    46 // ClockFormat
    47 // ClockFormat
   117     {    
   118     {    
   118     iCoeEnv->RemoveMessageMonitorObserver( *this );    
   119     iCoeEnv->RemoveMessageMonitorObserver( *this );    
   119 
   120 
   120     delete iLightObserver;    
   121     delete iLightObserver;    
   121     delete iClockControl;
   122     delete iClockControl;
   122     delete iDateControl;
       
   123     delete iDayControl;
       
   124     }
   123     }
   125 
   124 
   126 // -----------------------------------------------------------------------------
   125 // -----------------------------------------------------------------------------
   127 // CXnClockAdapter::ConstructL
   126 // CXnClockAdapter::ConstructL
   128 // Symbian 2nd phase constructor can leave.
   127 // Symbian 2nd phase constructor can leave.
   134     
   133     
   135     iForeground = iAvkonAppUi->IsForeground();
   134     iForeground = iAvkonAppUi->IsForeground();
   136     
   135     
   137     iLightObserver = CHWRMLight::NewL( this );
   136     iLightObserver = CHWRMLight::NewL( this );
   138     
   137     
   139     TBool useLocale;
       
   140     CXnProperty* prop( 
       
   141         iNode.GetPropertyL( XnPropertyNames::clock::KS60Format ) );
       
   142     TClockFormat format( ClockFormat( prop, useLocale ) );
       
   143     
       
   144     RPointerArray< CXnNodePluginIf > children( iNode.ChildrenL() );
   138     RPointerArray< CXnNodePluginIf > children( iNode.ChildrenL() );
   145     CleanupClosePushL( children );
   139     CleanupClosePushL( children );
   146     
   140     
   147     for ( TInt i = 0; i < children.Count(); i++ )
   141     for( TInt i = 0; i < children.Count(); i++ )
   148         {
   142         {
   149         CXnNodePluginIf* child( children[i] );
   143         CXnNodePluginIf* child( children[i] );
   150         const TDesC8& clocktype = child->Type()->Type();
   144         
   151         
   145         CXnProperty* id( child->IdL() );
   152         if ( clocktype == XnPropertyNames::clock::format::KDigital )
   146         
   153             {
   147         if( id )         
   154             iDigital = child;
   148             {
   155             }
   149             if( id->StringValue() == KDateInformation )
   156         else if ( clocktype == XnPropertyNames::clock::format::KAnalog )
       
   157             {
       
   158             iAnalog = child;
       
   159             }
       
   160         else if ( clocktype == XnPropertyNames::clock::KDate )
       
   161             {
       
   162             if ( !iDateControl )
       
   163                 {
   150                 {
   164                 iDateControl = CXnDateControl::NewL( *this, EDate );
   151                 iDate = child;                               
   165                 }
   152                 }
   166             iDate = child;
   153             else if( id->StringValue() == KDayInformation )
   167             }
       
   168 
       
   169         RPointerArray< CXnNodePluginIf > clockChildren( child->ChildrenL() );
       
   170         CleanupClosePushL( clockChildren );
       
   171         for ( TInt j = 0; j < clockChildren.Count(); j++ )
       
   172             {
       
   173             CXnNodePluginIf* clockChild( clockChildren[j] );
       
   174             const TDesC8& childType = clockChild->Type()->Type();
       
   175             
       
   176             if ( childType == XnPropertyNames::clock::KFace12 )
       
   177                 {
   154                 {
   178                 if ( !iClockControl )
   155                 iDay = child;
   179                     {
       
   180                     iClockControl = CXnClockControl::NewL( *this, useLocale, format );
       
   181                     }
       
   182                 iDigitalFace12 = clockChild;
       
   183                 }
   156                 }
   184             else if ( childType == XnPropertyNames::clock::KFace24 )
   157             }
   185                 {
       
   186                 if ( !iClockControl )
       
   187                     {
       
   188                     iClockControl = CXnClockControl::NewL( *this, useLocale, format );
       
   189                     }
       
   190                 iDigitalFace24 = clockChild;
       
   191                 }
       
   192             else if ( childType == XnPropertyNames::clock::KFace )
       
   193                {
       
   194                 if ( !iClockControl )
       
   195                     {
       
   196                     iClockControl = CXnClockControl::NewL( *this, useLocale, format );
       
   197                     }
       
   198                 iAnalogFace = clockChild;
       
   199                }
       
   200             else if ( childType == XnPropertyNames::clock::KDate &&
       
   201                       clocktype == XnPropertyNames::clock::format::KDigital )
       
   202                 {
       
   203                 if ( !iDateControl )
       
   204                     {
       
   205                     iDateControl = CXnDateControl::NewL( *this, EDate );
       
   206                     }
       
   207                 iDigitalDate = clockChild;
       
   208                 }
       
   209             else if ( childType == XnPropertyNames::clock::KDate &&
       
   210                       clocktype == XnPropertyNames::clock::format::KAnalog )
       
   211                 {
       
   212                 if ( !iDateControl )
       
   213                     {
       
   214                     iDateControl = CXnDateControl::NewL( *this, EDate );
       
   215                     }
       
   216                 iAnalogDate = clockChild;
       
   217                 }
       
   218             else if ( childType == XnPropertyNames::clock::KDay )
       
   219                {
       
   220                 if ( !iDayControl )
       
   221                     {
       
   222                     iDayControl = CXnDateControl::NewL( *this, EDay );
       
   223                     }
       
   224                 iDay = clockChild;
       
   225                }
       
   226             else if ( childType == XnPropertyNames::clock::KAmpm )
       
   227                {
       
   228                 iAmpm = clockChild;
       
   229                }
       
   230             }
       
   231         CleanupStack::PopAndDestroy( &clockChildren );
       
   232         }
   158         }
   233         
   159         
   234     CleanupStack::PopAndDestroy( &children );
   160     CleanupStack::PopAndDestroy( &children );
   235     
   161     
   236     SetClockFormatL( format );
   162     TBool useLocale;
       
   163 
       
   164     CXnProperty* prop( 
       
   165         iNode.GetPropertyL( XnPropertyNames::clock::KS60Format ) );    
       
   166     
       
   167     TClockFormat format( ClockFormat( prop, useLocale ) );   
       
   168     
       
   169     iClockControl = CXnClockControl::NewL( this, useLocale, format );    
   237     
   170     
   238     iCoeEnv->AddMessageMonitorObserverL( *this );
   171     iCoeEnv->AddMessageMonitorObserverL( *this );
   239 	}
   172 	}
   240 
       
   241 // -----------------------------------------------------------------------------
       
   242 // CXnClockAdapter::SetDisplayToBlockL
       
   243 // -----------------------------------------------------------------------------
       
   244 // 
       
   245 void CXnClockAdapter::SetDisplayToBlockL( CXnNodePluginIf& aNode, TBool aBlock )
       
   246     {
       
   247     CXnDomStringPool& sp = aNode.UiEngineL()->StringPool();
       
   248     CXnProperty* prop;
       
   249     if ( aBlock )
       
   250         {
       
   251         prop = CXnProperty::NewL( 
       
   252             KDisplay, KBlock, CXnDomPropertyValue::EString, sp );
       
   253         }
       
   254     else
       
   255         {
       
   256         prop = CXnProperty::NewL( 
       
   257             KDisplay, KNone, CXnDomPropertyValue::EString, sp );
       
   258         }
       
   259     CleanupStack::PushL( prop );
       
   260     aNode.SetPropertyL( prop );
       
   261     CleanupStack::Pop( prop );
       
   262     }
       
   263 
       
   264 // -----------------------------------------------------------------------------
       
   265 // CXnClockAdapter::SetClockFormatL
       
   266 // -----------------------------------------------------------------------------
       
   267 // 
       
   268 void CXnClockAdapter::SetClockFormatL( TClockFormat aFormat )
       
   269     {
       
   270     if ( iAnalog && iDigital )
       
   271         {
       
   272         if ( aFormat == EClockAnalog  )
       
   273             {
       
   274             SetDisplayToBlockL( *iAnalog, ETrue );
       
   275             SetDisplayToBlockL( *iDigital, EFalse );
       
   276             }
       
   277         else
       
   278             {
       
   279             SetDisplayToBlockL( *iDigital, ETrue );
       
   280             SetDisplayToBlockL( *iAnalog, EFalse );
       
   281             // check whether time format is 12 or 24
       
   282             if ( iDigitalFace12 && iDigitalFace24 )
       
   283                 {
       
   284                 if ( TLocale().TimeFormat() == ETime12 )
       
   285                     {
       
   286                     SetDisplayToBlockL( *iDigitalFace12, ETrue );
       
   287                     if ( iAmpm )
       
   288                         {
       
   289                         SetDisplayToBlockL( *iAmpm, ETrue );
       
   290                         }
       
   291                     SetDisplayToBlockL( *iDigitalFace24, EFalse );
       
   292                     }
       
   293                 else
       
   294                     {
       
   295                     SetDisplayToBlockL( *iDigitalFace24, ETrue );
       
   296                     SetDisplayToBlockL( *iDigitalFace12, EFalse );
       
   297                     if ( iAmpm )
       
   298                         {
       
   299                         SetDisplayToBlockL( *iAmpm, EFalse );
       
   300                         }
       
   301                     }
       
   302                 }
       
   303             }
       
   304         iNode.UiEngineL()->LayoutUIL( &iNode );
       
   305         }
       
   306     }
       
   307  
   173  
   308 // -----------------------------------------------------------------------------
   174 // -----------------------------------------------------------------------------
   309 // CXnClockAdapter::DoHandlePropertyChangeL
   175 // CXnClockAdapter::DoHandlePropertyChangeL
       
   176 //
   310 // -----------------------------------------------------------------------------
   177 // -----------------------------------------------------------------------------
   311 //
   178 //
   312 void CXnClockAdapter::DoHandlePropertyChangeL( CXnProperty* aProperty )
   179 void CXnClockAdapter::DoHandlePropertyChangeL( CXnProperty* aProperty )
   313     {        
   180     {        
   314     if( aProperty )
   181     if( aProperty )
   315         {
   182         {
   316         const TDesC8& name( aProperty->Property()->Name() );
   183         const TDesC8& name( aProperty->Property()->Name() );
   317         
   184         
   318         if( iClockControl && name == XnPropertyNames::clock::KS60Format )
   185         if( name == XnPropertyNames::clock::KS60Format )
   319             {
   186             {
   320             TBool useLocale;
   187             TBool useLocale;
   321             
   188             
   322             TClockFormat format( ClockFormat( aProperty, useLocale ) );
   189             TClockFormat format( ClockFormat( aProperty, useLocale ) );
   323             
   190             
   324             iClockControl->SetFormatL( useLocale, format );
   191             iClockControl->SetFormatL( useLocale, format );
   325             }
   192             }
       
   193         else if( name == XnPropertyNames::clock::KS60DigitalFontSize )            
       
   194             {
       
   195             iDigitalFont = NULL;            
       
   196             }
       
   197         else if( name == XnPropertyNames::clock::KS60AmPmFontSize )
       
   198             {
       
   199             iAmPmFont = NULL;
       
   200             }
       
   201         else if( name == XnPropertyNames::clock::KS60DateFontSize )
       
   202             {
       
   203             iDateFont = NULL;
       
   204             }
       
   205         else if( name == XnPropertyNames::appearance::common::KColor )
       
   206             {
       
   207             iColorSet = EFalse;
       
   208             }
   326         }
   209         }
   327     }
   210     }
   328 
   211 
   329 // -----------------------------------------------------------------------------
   212 // -----------------------------------------------------------------------------
   330 // CXnClockAdapter::UpdateDisplay
   213 // CXnClockAdapter::UpdateDisplay
       
   214 // Draws the clock component
   331 // -----------------------------------------------------------------------------
   215 // -----------------------------------------------------------------------------
   332 //
   216 //
   333 void CXnClockAdapter::UpdateDisplay() const
   217 void CXnClockAdapter::UpdateDisplay() const
   334     {    
   218     {    
   335     if ( !iNode.Rect().IsEmpty() )
   219     if ( !iNode.Rect().IsEmpty() )
   338         }
   222         }
   339     }
   223     }
   340 
   224 
   341 // -----------------------------------------------------------------------------
   225 // -----------------------------------------------------------------------------
   342 // CXnClockAdapter::Draw
   226 // CXnClockAdapter::Draw
       
   227 // Draws the clock component
   343 // -----------------------------------------------------------------------------
   228 // -----------------------------------------------------------------------------
   344 //
   229 //
   345 void CXnClockAdapter::Draw( const TRect& aRect ) const
   230 void CXnClockAdapter::Draw( const TRect& aRect ) const
   346     {                           
   231     {                           
   347     CXnControlAdapter::Draw( aRect );
   232     CXnControlAdapter::Draw( aRect );
   348     
   233     
   349     CWindowGc& gc( SystemGc() );
   234     CWindowGc& gc( SystemGc() );
   350 
   235            
   351     if ( iClockControl )
   236     iClockControl->Draw( gc, iNode.Rect() );
   352         {
       
   353         TClockFormat format = iClockControl->Format();
       
   354         if ( format == EClockAnalog )
       
   355             {
       
   356             iClockControl->Draw( gc, iAnalogFace, NULL );
       
   357             }
       
   358         else
       
   359             {
       
   360             if ( TLocale().TimeFormat() == ETime12 )
       
   361                 {
       
   362                 iClockControl->Draw( gc, iDigitalFace12, iAmpm );
       
   363                 }
       
   364             else
       
   365                 {
       
   366                 iClockControl->Draw( gc, iDigitalFace24, NULL );
       
   367                 }
       
   368             }
       
   369         }
       
   370     
       
   371     if ( iDateControl )
       
   372         {
       
   373         if ( iClockControl && iClockControl->Format() == EClockAnalog && iAnalogDate )
       
   374             {
       
   375             TRAP_IGNORE( iDateControl->DrawL( gc, iAnalogDate ) );
       
   376             }
       
   377         else if ( iClockControl && iClockControl->Format() == EClockDigital && iDigitalDate )
       
   378             {
       
   379             TRAP_IGNORE( iDateControl->DrawL( gc, iDigitalDate ) );
       
   380             }
       
   381         else
       
   382             {
       
   383             TRAP_IGNORE( iDateControl->DrawL( gc, iDate ) );
       
   384             }
       
   385         }
       
   386     
       
   387     if ( iDayControl )
       
   388         {
       
   389         TRAP_IGNORE( iDayControl->DrawL( gc, iDay ) );
       
   390         }
       
   391     }
   237     }
   392 
   238 
   393 // -----------------------------------------------------------------------------
   239 // -----------------------------------------------------------------------------
   394 // CXnClockAdapter::MakeVisible
   240 // CXnClockAdapter::MakeVisible
       
   241 // 
   395 // -----------------------------------------------------------------------------
   242 // -----------------------------------------------------------------------------
   396 //        
   243 //        
   397 void CXnClockAdapter::MakeVisible( TBool aVisible )
   244 void CXnClockAdapter::MakeVisible( TBool aVisible )
   398     {
   245     {
   399     TBool visible( IsVisible() );
   246     TBool visible( IsVisible() );
   414         }
   261         }
   415     }
   262     }
   416 
   263 
   417 // -----------------------------------------------------------------------------
   264 // -----------------------------------------------------------------------------
   418 // CXnClockAdapter::MonitorWsMessage
   265 // CXnClockAdapter::MonitorWsMessage
       
   266 // 
   419 // -----------------------------------------------------------------------------
   267 // -----------------------------------------------------------------------------
   420 //    
   268 //    
   421 void CXnClockAdapter::MonitorWsMessage( const TWsEvent& aEvent )
   269 void CXnClockAdapter::MonitorWsMessage( const TWsEvent& aEvent )
   422     {   
   270     {   
   423     TInt type( aEvent.Type() );
   271     TInt type( aEvent.Type() );
   434         }
   282         }
   435 
   283 
   436     if( foreground != iForeground )            
   284     if( foreground != iForeground )            
   437         {
   285         {
   438         if( iForeground )
   286         if( iForeground )
   439             {
   287             {   
   440             // check if clock format has changed
       
   441             if ( iClockControl )
       
   442                 {
       
   443                 TRAP_IGNORE( iClockControl->CheckClockFormatL() );
       
   444                 }
       
   445             UpdateDisplay();
   288             UpdateDisplay();
       
   289             
   446             // Start clock ensures UI state
   290             // Start clock ensures UI state
   447             StartClock();
   291             StartClock();
   448             }
   292             }
   449         else
   293         else
   450             {
   294             {
   453         }
   297         }
   454     }
   298     }
   455 
   299 
   456 // -----------------------------------------------------------------------------
   300 // -----------------------------------------------------------------------------
   457 // CXnClockAdapter::LightStatusChanged
   301 // CXnClockAdapter::LightStatusChanged
       
   302 // 
   458 // -----------------------------------------------------------------------------
   303 // -----------------------------------------------------------------------------
   459 //    
   304 //    
   460 void CXnClockAdapter::LightStatusChanged( TInt aTarget, 
   305 void CXnClockAdapter::LightStatusChanged( TInt aTarget, 
   461     CHWRMLight::TLightStatus aStatus )
   306     CHWRMLight::TLightStatus aStatus )
   462     {
   307     {
   481             StopClock();
   326             StopClock();
   482             }        
   327             }        
   483         }
   328         }
   484     }
   329     }
   485 
   330 
   486 // -----------------------------------------------------------------------------
   331 
   487 // CXnClockAdapter::GetTextAlignL
   332 // -----------------------------------------------------------------------------
   488 // -----------------------------------------------------------------------------
   333 // CXnClockAdapter::FontL
   489 // 
   334 // 
   490 CGraphicsContext::TTextAlign CXnClockAdapter::GetTextAlignL( CXnNodePluginIf& aNode )
   335 // -----------------------------------------------------------------------------
   491     {
   336 //    
   492     CGraphicsContext::TTextAlign ret = CGraphicsContext::ECenter;
   337 const CAknLayoutFont* CXnClockAdapter::FontL( const TInt aType )
   493     CXnProperty* prop( aNode.GetPropertyL( 
   338     {
   494             XnPropertyNames::appearance::common::KTextAlign ) );
   339     CFont* font( NULL );
   495     
   340     
   496     if( prop )
   341     if( aType == EDigitalFont )
   497         {
   342         {
   498         if ( prop->StringValue() ==
   343         if( !iDigitalFont )
   499                 XnPropertyNames::appearance::common::textalign::KAlignLeft )
   344             {            
   500             {
   345             CreateFontL( aType );
   501             ret = CGraphicsContext::ELeft;
   346             }
   502             }
   347         
   503         else if ( prop->StringValue() ==
   348         font = iDigitalFont;        
   504                 XnPropertyNames::appearance::common::textalign::KAlignRight )
   349         }
   505             {
   350     else if( aType == EAmPmFont )
   506             ret = CGraphicsContext::ERight;
   351         {
   507             }
   352         if( !iAmPmFont )
   508         else if ( prop->StringValue() ==
   353             {
   509                 XnPropertyNames::appearance::common::textalign::KAlignCenter )
   354             CreateFontL( aType );        
   510             {
   355             }
   511             ret = CGraphicsContext::ECenter;
   356         
   512             }
   357         font = iAmPmFont;
   513         }
   358         }
   514     return ret;
   359     else if( aType == EDateFont )
       
   360         {
       
   361         if( !iDateFont )
       
   362             {
       
   363             CreateFontL( aType );        
       
   364             }
       
   365         
       
   366         font = iDateFont;        
       
   367         }
       
   368     
       
   369     if( font )
       
   370         {
       
   371         return CAknLayoutFont::AsCAknLayoutFontOrNull( font );
       
   372         }
       
   373     
       
   374     return NULL;
       
   375     }
       
   376 
       
   377 // -----------------------------------------------------------------------------
       
   378 // CXnClockAdapter::TextColorL
       
   379 // 
       
   380 // -----------------------------------------------------------------------------
       
   381 //    
       
   382 const TRgb& CXnClockAdapter::TextColorL()
       
   383     {    
       
   384     if( !iColorSet )
       
   385         {
       
   386         CreateColorL();
       
   387         }
       
   388         
       
   389     return iColor;            
       
   390     }
       
   391 
       
   392 // -----------------------------------------------------------------------------
       
   393 // CXnClockAdapter::Date
       
   394 // 
       
   395 // -----------------------------------------------------------------------------
       
   396 //    
       
   397 CXnNodePluginIf* CXnClockAdapter::Date() const
       
   398     {
       
   399     return iDate;
       
   400     }
       
   401 
       
   402 // -----------------------------------------------------------------------------
       
   403 // CXnClockAdapter::Day
       
   404 // 
       
   405 // -----------------------------------------------------------------------------
       
   406 //    
       
   407 CXnNodePluginIf* CXnClockAdapter::Day() const
       
   408     {
       
   409     return iDay;
   515     }
   410     }
   516 
   411 
   517 // -----------------------------------------------------------------------------
   412 // -----------------------------------------------------------------------------
   518 // CXnClockAdapter::CreateFontL
   413 // CXnClockAdapter::CreateFontL
   519 // -----------------------------------------------------------------------------
   414 // 
   520 //    
   415 // -----------------------------------------------------------------------------
   521 void CXnClockAdapter::CreateFontL( CXnNodePluginIf& aNode,
   416 //    
   522                                    CFont*& aFont )
   417 void CXnClockAdapter::CreateFontL( const TInt aType )   
   523     {
   418     {
   524     TFontSpec spec;
   419     TFontSpec spec;
   525     TInt dummy;
   420     TInt dummy;
   526     
   421 
   527     CXnProperty* prop( aNode.GetPropertyL( 
   422     if( aType == EDigitalFont )
   528         XnPropertyNames::clock::KS60FontSize ) );
   423         {
   529 
   424         iDigitalFont = NULL;
   530     // default
   425         
   531     TInt height( ( aNode.Rect().Height() / 5 ) );
   426         CXnProperty* prop( iNode.GetPropertyL( 
   532 
   427             XnPropertyNames::clock::KS60DigitalFontSize ) );
   533     if ( prop )
   428 
   534         {
   429         // default
   535         height = aNode.UiEngineL()->VerticalPixelValueL(
   430         TInt height( ( iNode.Rect().Height() / 3 ) * 2 );
   536             prop, aNode.Rect().Height() );
   431 
   537         }
       
   538     else
       
   539         {
       
   540         // check if fontsize is defined in clock element
       
   541         prop = iNode.GetPropertyL( 
       
   542             XnPropertyNames::clock::KS60FontSize );
       
   543         if ( prop )
   432         if ( prop )
   544             {
   433             {
   545             height = iNode.UiEngineL()->VerticalPixelValueL(
   434             height = iNode.UiEngineL()->VerticalPixelValueL(
   546                 prop, iNode.Rect().Height() );
   435                 prop, iNode.Rect().Height() );
   547             }
   436             }
   548         }
   437                                             
   549     
       
   550     TBool fontNotSet( ETrue );
       
   551     prop = aNode.GetPropertyL(
       
   552             XnPropertyNames::appearance::common::KFontFamily );
       
   553     
       
   554     if ( prop )
       
   555         {
       
   556         CXnDomPropertyValue* value = static_cast< CXnDomPropertyValue* >(
       
   557             prop->Property()->PropertyValueList().Item( 0 ) );
       
   558         
       
   559         if ( CXnDomPropertyValue::EIdent == value->PrimitiveValueType()
       
   560                 ||CXnDomPropertyValue::EString == value->PrimitiveValueType() )
       
   561             {
       
   562             const TDesC& fontName( prop->StringValueL()->Des() );
       
   563             
       
   564             // No need to relase avkon font
       
   565             CXnUtils::CreateFontL( fontName, 
       
   566                                    height,
       
   567                                    spec.iFontStyle,
       
   568                                    aFont,
       
   569                                    dummy );
       
   570             
       
   571             fontNotSet = EFalse;
       
   572             }
       
   573         }
       
   574     
       
   575     if( fontNotSet )
       
   576         {
       
   577         // No need to relase avkon font
   438         // No need to relase avkon font
   578         CXnUtils::CreateFontL( KLogicalSecondaryFont, 
   439         CXnUtils::CreateFontL( KDigitalFont, 
   579                                height,
   440                                height,
   580                                spec.iFontStyle,
   441                                spec.iFontStyle,
   581                                aFont,
   442                                iDigitalFont,
   582                                dummy );
   443                                dummy );
   583         }
   444         }
       
   445     else if( aType == EAmPmFont )
       
   446         {
       
   447         iAmPmFont = NULL;
       
   448 
       
   449         CXnProperty* prop( iNode.GetPropertyL( 
       
   450             XnPropertyNames::clock::KS60AmPmFontSize ) );
       
   451         
       
   452         // default
       
   453         TInt height( ( iNode.Rect().Height() / 5 ) );
       
   454 
       
   455         if ( prop )
       
   456             {
       
   457             height = iNode.UiEngineL()->VerticalPixelValueL(
       
   458                 prop, iNode.Rect().Height() );
       
   459             }        
       
   460         
       
   461         // No need to relase avkon font
       
   462         CXnUtils::CreateFontL( KAmPmFont, 
       
   463                                height,
       
   464                                spec.iFontStyle,
       
   465                                iAmPmFont,
       
   466                                dummy );      
       
   467         }
       
   468     else if( aType == EDateFont )
       
   469         {
       
   470         iDateFont = NULL;
       
   471         
       
   472         CXnProperty* prop( iNode.GetPropertyL( 
       
   473             XnPropertyNames::clock::KS60DateFontSize ) );
       
   474         
       
   475         // default 
       
   476         TInt height( ( iNode.Rect().Height() / 5 ) );
       
   477         
       
   478         if ( prop )
       
   479             {
       
   480             height = iNode.UiEngineL()->VerticalPixelValueL(
       
   481                 prop, iNode.Rect().Height() );
       
   482             }
       
   483         
       
   484         // No need to relase avkon font
       
   485         CXnUtils::CreateFontL( KDateFont, 
       
   486                                height,
       
   487                                spec.iFontStyle,
       
   488                                iDateFont,
       
   489                                dummy );              
       
   490         }
   584     }
   491     }
   585 
   492 
   586 // -----------------------------------------------------------------------------
   493 // -----------------------------------------------------------------------------
   587 // CXnClockAdapter::CreateColorL
   494 // CXnClockAdapter::CreateColorL
   588 // -----------------------------------------------------------------------------
   495 // 
   589 //    
   496 // -----------------------------------------------------------------------------
   590 void CXnClockAdapter::CreateColorL( CXnNodePluginIf& aNode, TRgb& aColor )
   497 //    
       
   498 void CXnClockAdapter::CreateColorL()
   591     {        
   499     {        
   592     TRgb color;
   500     TRgb color;
   593             
   501             
   594     TInt result( KErrNone );
   502     TInt result( KErrNone );
   595         
   503         
   596     CXnProperty* prop( aNode.GetPropertyL( 
   504     CXnProperty* prop( iNode.GetPropertyL( 
   597         XnPropertyNames::appearance::common::KColor ) );
   505         XnPropertyNames::appearance::common::KColor ) );
   598     
   506     
   599     if( !prop )
   507     if( !prop )
   600         {
   508         {
   601         // check if color is defined in clock element
   509         return;
   602         prop = iNode.GetPropertyL( 
       
   603             XnPropertyNames::appearance::common::KColor );
       
   604         if ( !prop )
       
   605             {
       
   606             return;
       
   607             }
       
   608         }
   510         }
   609         
   511         
   610     CXnDomProperty* domProp( prop->Property() );
   512     CXnDomProperty* domProp( prop->Property() );
   611     
   513     
   612     MAknsSkinInstance* skin( AknsUtils::SkinInstance() );
   514     MAknsSkinInstance* skin( AknsUtils::SkinInstance() );
   650             }
   552             }
   651         }
   553         }
   652         
   554         
   653     if( result == KErrNone )
   555     if( result == KErrNone )
   654         {
   556         {
   655         aColor = color;
   557         iColorSet = ETrue;
       
   558         iColor = color;
   656         }            
   559         }            
   657     }
   560     }
   658 
   561 
   659 // -----------------------------------------------------------------------------
   562 // -----------------------------------------------------------------------------
   660 // CXnClockAdapter::SkinChanged
   563 // CXnClockAdapter::SkinChanged
       
   564 // Skin change notification
   661 // -----------------------------------------------------------------------------
   565 // -----------------------------------------------------------------------------
   662 //  
   566 //  
   663 void CXnClockAdapter::SkinChanged()
   567 void CXnClockAdapter::SkinChanged()
   664     {
   568     {
   665     if ( iClockControl )
   569     iAmPmFont = iDigitalFont = iDateFont = NULL;
   666         {
   570     iColorSet = EFalse;
   667         iClockControl->ResetFont();
       
   668         }
       
   669     if ( iDateControl )
       
   670         {
       
   671         iDateControl->ResetFont();
       
   672         }
       
   673     if ( iDayControl )
       
   674         {
       
   675         iDayControl->ResetFont();
       
   676         }
       
   677     
   571     
   678     CXnControlAdapter::SkinChanged();
   572     CXnControlAdapter::SkinChanged();
   679     }
   573     }
   680 
   574 
   681 // -----------------------------------------------------------------------------
   575 // -----------------------------------------------------------------------------
   682 // CXnClockAdapter::HandleScreenDeviceChangedL
   576 // CXnClockAdapter::HandleScreenDeviceChangedL
       
   577 // Screen device change notification
   683 // -----------------------------------------------------------------------------
   578 // -----------------------------------------------------------------------------
   684 //  
   579 //  
   685 void CXnClockAdapter::HandleScreenDeviceChangedL()
   580 void CXnClockAdapter::HandleScreenDeviceChangedL()
   686     {
   581     {
   687     if ( iClockControl )
   582     iAmPmFont = iDigitalFont = iDateFont = NULL;
   688         {
   583     iColorSet = EFalse;
   689         iClockControl->ResetFont();
       
   690         }
       
   691     if ( iDateControl )
       
   692         {
       
   693         iDateControl->ResetFont();
       
   694         }
       
   695     if ( iDayControl )
       
   696         {
       
   697         iDayControl->ResetFont();
       
   698         }
       
   699     
   584     
   700     CXnControlAdapter::HandleScreenDeviceChangedL();
   585     CXnControlAdapter::HandleScreenDeviceChangedL();
   701     }
   586     }
   702 
   587 
   703 // -----------------------------------------------------------------------------
   588 // -----------------------------------------------------------------------------
   704 // CXnClockAdapter::SizeChanged
   589 // CXnClockAdapter::SizeChanged
       
   590 // Size changed notification
   705 // -----------------------------------------------------------------------------
   591 // -----------------------------------------------------------------------------
   706 //  
   592 //  
   707 void CXnClockAdapter::SizeChanged()
   593 void CXnClockAdapter::SizeChanged()
   708     {
   594     {
   709     if ( iClockControl )
   595     iAmPmFont = iDigitalFont = iDateFont = NULL;
   710         {
   596     iColorSet = EFalse;
   711         iClockControl->ResetFont();
       
   712         }
       
   713     if ( iDateControl )
       
   714         {
       
   715         iDateControl->ResetFont();
       
   716         }
       
   717     if ( iDayControl )
       
   718         {
       
   719         iDayControl->ResetFont();
       
   720         }
       
   721     
   597     
   722     CXnControlAdapter::SizeChanged();    
   598     CXnControlAdapter::SizeChanged();    
   723     }
   599     }
   724 
   600 
   725 // -----------------------------------------------------------------------------
   601 // -----------------------------------------------------------------------------
   726 // CXnClockAdapter::StartClock
   602 // CXnClockAdapter::StartClock
       
   603 // 
   727 // -----------------------------------------------------------------------------
   604 // -----------------------------------------------------------------------------
   728 // 
   605 // 
   729 void CXnClockAdapter::StartClock()
   606 void CXnClockAdapter::StartClock()
   730     {    
   607     {    
   731     if ( iClockControl )
   608     if ( iClockControl )
   741         }
   618         }
   742     }
   619     }
   743 
   620 
   744 // -----------------------------------------------------------------------------
   621 // -----------------------------------------------------------------------------
   745 // CXnClockAdapter::StopClock
   622 // CXnClockAdapter::StopClock
       
   623 // 
   746 // -----------------------------------------------------------------------------
   624 // -----------------------------------------------------------------------------
   747 // 
   625 // 
   748 void CXnClockAdapter::StopClock()
   626 void CXnClockAdapter::StopClock()
   749     {
   627     {
   750     if ( iClockControl )
   628     if ( iClockControl )
   751         {
   629         {
   752         iClockControl->StopTimer();
   630         iClockControl->StopTimer();
   753         }
   631         }    
   754     }
   632     }
   755 
   633 
   756 // End of file
   634 // End of file