idlehomescreen/xmluirendering/renderingplugins/xnnewstickerfactory/src/xnnewstickeradapter.cpp
changeset 0 f72a12da539e
child 2 08c6ee43b396
equal deleted inserted replaced
-1:000000000000 0:f72a12da539e
       
     1 /*
       
     2 * Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Implementation for wrapper for a label
       
    15 *
       
    16 */
       
    17 
       
    18 // System includes
       
    19 #include <utf.h>
       
    20 #include <AknsUtils.h>
       
    21 #include <AknUtils.h>
       
    22 
       
    23 // User includes
       
    24 #include "xnviewnodeimpl.h"
       
    25 #include "xndompropertyvalue.h"
       
    26 #include "xndomlist.h"
       
    27 #include "xnproperty.h"
       
    28 #include "xnnodepluginif.h"
       
    29 #include "xntype.h" 
       
    30 
       
    31 #include "c_xnutils.h"
       
    32 
       
    33 #include "xnnewstickeradapter.h"
       
    34 #include "xnnewstickercontrol.h"
       
    35 #include "xnnewstickersvgcontrol.h"
       
    36 #include "xncomponentnodeimpl.h"
       
    37 
       
    38 // ============================= LOCAL FUNCTIONS ===============================
       
    39 
       
    40 // -----------------------------------------------------------------------------
       
    41 // GetIntPropertyL
       
    42 // Gets an integer property from the node.
       
    43 // Returns: aNode UI node
       
    44 //          aproperty The property that is to be found
       
    45 //          return The value of the property. If not found, KErrNotFound returned.
       
    46 // -----------------------------------------------------------------------------
       
    47 // 
       
    48 static TInt GetIntPropertyL(
       
    49     CXnNodePluginIf& aNode,
       
    50     const TDesC8& aProperty)
       
    51     {
       
    52     CXnProperty* prop = aNode.GetPropertyL(aProperty);
       
    53     if(prop)
       
    54         {        
       
    55         CXnDomPropertyValue* value = 
       
    56             static_cast<CXnDomPropertyValue*>(prop->Property()->PropertyValueList().Item(0));
       
    57         if(CXnDomPropertyValue::ENumber == value->PrimitiveValueType())
       
    58             {
       
    59             TInt integer = static_cast<TInt>(prop->FloatValueL());
       
    60             return integer;
       
    61             }
       
    62         }
       
    63     return KErrNotFound;
       
    64     }
       
    65 
       
    66 // -----------------------------------------------------------------------------
       
    67 // CopyBitmapData
       
    68 // Copies a data from source bitmap to target bitmap.
       
    69 // -----------------------------------------------------------------------------
       
    70 //
       
    71 static TInt CopyBitmapData(
       
    72     CFbsBitmap& aTarget,
       
    73     const CFbsBitmap& aSource,
       
    74     TPoint aSourcePoint)
       
    75 	{
       
    76     TSize targetSize(aTarget.SizeInPixels());
       
    77     TSize sourceSize(aSource.SizeInPixels());
       
    78     TInt lineLength(targetSize.iWidth);
       
    79     TInt maxSourceLineLength(sourceSize.iWidth - aSourcePoint.iX);
       
    80     if(lineLength > maxSourceLineLength)
       
    81         {
       
    82         lineLength = maxSourceLineLength;
       
    83         }
       
    84     TInt rowCount(targetSize.iHeight);
       
    85     TInt maxSourceRowCount(sourceSize.iHeight - aSourcePoint.iY);
       
    86     if(rowCount > maxSourceRowCount)
       
    87         {
       
    88         rowCount = maxSourceRowCount;
       
    89         }
       
    90 
       
    91     // Get bitmap display mode
       
    92 	TDisplayMode displayMode(aSource.DisplayMode());
       
    93 
       
    94     // Create buffer for a scan line
       
    95 	HBufC8* scanLine = HBufC8::New(
       
    96         aSource.ScanLineLength(lineLength, displayMode));
       
    97     if(!scanLine)
       
    98     	{
       
    99     	return KErrNoMemory;
       
   100     	}
       
   101      
       
   102 	TPtr8 scanPtr(scanLine->Des());
       
   103 
       
   104     // Copy all rows to destination bitmap
       
   105 	for(TInt row(0); row < rowCount; row++)
       
   106 		{
       
   107 		aSource.GetScanLine(scanPtr,
       
   108             TPoint(aSourcePoint.iX, aSourcePoint.iY + row),
       
   109             lineLength, displayMode);
       
   110 		aTarget.SetScanLine(scanPtr, row);
       
   111 		}
       
   112     delete scanLine;
       
   113 	return KErrNone;
       
   114 	}        
       
   115 
       
   116 // ---------------------------------------------------------
       
   117 // CXnNewstickerAdapter::CheckDisplayL
       
   118 // ---------------------------------------------------------
       
   119 //
       
   120 TBool CXnNewstickerAdapter::CheckDisplayL( CXnNodePluginIf& aNode )
       
   121     {
       
   122     if( iPowerSaveMode )
       
   123         {
       
   124         iDisplay = EFalse;
       
   125         
       
   126         return iDisplay;
       
   127         }
       
   128         
       
   129 	CXnProperty* displayProp( aNode.DisplayL() );
       
   130 
       
   131 	if( displayProp )
       
   132 	    {
       
   133 	    const TDesC8& display( displayProp->StringValue() );
       
   134 	    
       
   135 	    if( display != XnPropertyNames::style::common::display::KBlock )
       
   136 	        {
       
   137 	        return EFalse;
       
   138 	        }
       
   139 	    }
       
   140     
       
   141 	CXnProperty* visibilityProp( aNode.VisibilityL());
       
   142 
       
   143 	if( visibilityProp )
       
   144 	    {
       
   145 	    const TDesC8& visibility( visibilityProp->StringValue() );
       
   146 	    
       
   147 	    if( visibility != XnPropertyNames::style::common::visibility::KVisible )
       
   148 	        {
       
   149 	        return EFalse;
       
   150 	        }
       
   151 	    }
       
   152     
       
   153     
       
   154     CXnNodePluginIf* parent( aNode.ParentL() );
       
   155     
       
   156     TBool ret( ETrue );
       
   157     
       
   158     if( parent )
       
   159         {
       
   160         ret = CheckDisplayL( *parent );
       
   161         }
       
   162         
       
   163     iDisplay = ret;  
       
   164     
       
   165     return iDisplay;          
       
   166     }
       
   167 
       
   168 // ---------------------------------------------------------
       
   169 // CXnNewstickerAdapter::SetNewstickerPropertiesL
       
   170 // ---------------------------------------------------------
       
   171 //
       
   172 void CXnNewstickerAdapter::SetNewstickerPropertiesL()
       
   173     {
       
   174     // scroll amount 
       
   175     TInt scrollamount = GetIntPropertyL( iNode, 
       
   176         XnPropertyNames::newsticker::KXnScrollAmount );   // px
       
   177     
       
   178     if( KErrNotFound == scrollamount )
       
   179         {
       
   180         scrollamount = KXnNewstickerScrollAmount;
       
   181         }
       
   182 
       
   183     CXnProperty* prop( iNode.GetPropertyL( XnPropertyNames::newsticker::KScrollBehaviour ) );
       
   184     
       
   185     if( prop )
       
   186         {
       
   187         if ( prop->StringValue() == XnPropertyNames::newsticker::scroll_behaviour::KAlternate )
       
   188             {
       
   189             scrollamount = 0;
       
   190             iScrollBehaviour = EAlternate;
       
   191             }
       
   192         else if ( prop->StringValue() == XnPropertyNames::newsticker::scroll_behaviour::KSlide )
       
   193             {
       
   194             iScrollBehaviour = ESlide;
       
   195             }
       
   196         else if ( prop->StringValue() == XnPropertyNames::newsticker::scroll_behaviour::KScrollAlternate )
       
   197             {
       
   198             iScrollBehaviour = EScrollAlternate;
       
   199             }
       
   200         else
       
   201             {
       
   202             iScrollBehaviour = EScroll;
       
   203             }
       
   204         }
       
   205     else
       
   206         {
       
   207         iScrollBehaviour = EScroll;
       
   208         }        
       
   209         
       
   210     iControl->SetScrollAmount( scrollamount );
       
   211     
       
   212     if( iScrollBehaviour == EScroll || iScrollBehaviour == ESlide )
       
   213         {                    
       
   214         // scroll delay
       
   215         TInt scrolldelay = GetIntPropertyL( iNode, 
       
   216             XnPropertyNames::newsticker::KXnScrollDelay );  // ms
       
   217         
       
   218         if( KErrNotFound == scrolldelay )
       
   219             {
       
   220             scrolldelay = KXnNewstickerInterval;
       
   221             }
       
   222         else 
       
   223             {
       
   224             scrolldelay *= 1000;    // change to microseconds
       
   225             }
       
   226         
       
   227         iInterval = scrolldelay;
       
   228             
       
   229         // start delay
       
   230         TInt startdelay = GetIntPropertyL( iNode, 
       
   231             XnPropertyNames::newsticker::KXnStartDelay ); // ms
       
   232         
       
   233         if( KErrNotFound == startdelay )
       
   234             {
       
   235             startdelay = KXnNewstickerDelay;
       
   236             }
       
   237         else 
       
   238             {
       
   239             startdelay *= 1000;    // change to microseconds
       
   240             }
       
   241         
       
   242         iDelay = startdelay;
       
   243         }
       
   244     else if( iScrollBehaviour == EScrollAlternate )
       
   245 		{
       
   246         // scroll delay
       
   247         TInt scrolldelay = GetIntPropertyL( iNode, 
       
   248             XnPropertyNames::newsticker::KXnScrollDelay );  // ms
       
   249         
       
   250         if( KErrNotFound == scrolldelay )
       
   251             {
       
   252             scrolldelay = KXnNewstickerInterval;
       
   253             }
       
   254         else 
       
   255             {
       
   256             scrolldelay *= 1000;    // change to microseconds
       
   257             }
       
   258         
       
   259         iInterval = scrolldelay;
       
   260 
       
   261         TInt alternateTime( GetIntPropertyL( iNode, XnPropertyNames::newsticker::KDisplayTime ) );
       
   262         
       
   263         if( alternateTime == KErrNotFound )
       
   264             {
       
   265             alternateTime = 0;
       
   266             }
       
   267 
       
   268         alternateTime *= 1000; // change to ms                        
       
   269 
       
   270         iAlternateInterval = alternateTime;
       
   271 
       
   272         // start delay
       
   273         TInt startdelay = GetIntPropertyL( iNode, 
       
   274             XnPropertyNames::newsticker::KXnStartDelay ); // ms
       
   275         
       
   276         if( KErrNotFound == startdelay )
       
   277             {
       
   278             startdelay = 0;
       
   279             }
       
   280         else 
       
   281             {
       
   282             startdelay *= 1000;    // change to microseconds
       
   283             }
       
   284         
       
   285         iDelay = startdelay;
       
   286         }
       
   287     else // TScrollBehaviour::EAlternate
       
   288         {
       
   289         TInt alternateTime( GetIntPropertyL( iNode, XnPropertyNames::newsticker::KDisplayTime ) );
       
   290         
       
   291         if( alternateTime == KErrNotFound )
       
   292             {
       
   293             alternateTime = 0;
       
   294             }
       
   295 
       
   296         alternateTime *= 1000; // change to ms                        
       
   297 
       
   298         iDelay = 0;
       
   299         iInterval = alternateTime;
       
   300         }        
       
   301 
       
   302     //  animation time
       
   303     iAnimationTime = GetIntPropertyL( iNode, 
       
   304         XnPropertyNames::newsticker::KXnNewstickerAnimationDelay );  // ms
       
   305     
       
   306     if( KErrNotFound == iAnimationTime )
       
   307         {
       
   308         iAnimationTime = KAnimationTime;
       
   309         }
       
   310     else 
       
   311         {
       
   312         iAnimationTime *= 1000;    // change to microseconds
       
   313         }
       
   314     
       
   315     // _s60-scroll-loop property. True by default.
       
   316     CXnProperty* loopProp( iNode.GetPropertyL( XnPropertyNames::newsticker::KScrollLoop ) );
       
   317     
       
   318     if( loopProp && loopProp->StringValue() == XnPropertyNames::KFalse )
       
   319         {
       
   320         iControl->SetScrollLooping( EFalse );
       
   321         }
       
   322     else
       
   323         {
       
   324         iControl->SetScrollLooping( ETrue );
       
   325         }            
       
   326     CXnProperty* restartProperty( iNode.GetPropertyL( XnPropertyNames::newsticker::KRestartAfterUpdate ) );
       
   327     if ( restartProperty && restartProperty->StringValue() == XnPropertyNames::KTrue )
       
   328         {
       
   329         iRestartAfterUpdate = ETrue;
       
   330         }
       
   331      }
       
   332 
       
   333 // ============================ MEMBER FUNCTIONS ===============================
       
   334 
       
   335 // -----------------------------------------------------------------------------
       
   336 // CXnNewstickerAdapter::NewL
       
   337 // Symbian static 1st phase constructor
       
   338 // -----------------------------------------------------------------------------
       
   339 //
       
   340 CXnNewstickerAdapter* CXnNewstickerAdapter::NewL(CXnControlAdapter* aParent, 
       
   341     CXnNodePluginIf& aNode)
       
   342     {
       
   343 	CXnNewstickerAdapter* self = new( ELeave ) CXnNewstickerAdapter( aParent, aNode );
       
   344     CleanupStack::PushL( self );
       
   345     self->ConstructL();
       
   346     CleanupStack::Pop();
       
   347     return self;	
       
   348     }
       
   349 
       
   350 // -----------------------------------------------------------------------------
       
   351 // CXnNewstickerAdapter::ConstructL
       
   352 // Symbian 2nd phase constructor can leave.
       
   353 // -----------------------------------------------------------------------------
       
   354 //
       
   355 void CXnNewstickerAdapter::ConstructL()
       
   356     {
       
   357     CXnControlAdapter::ConstructL( iNode );
       
   358     
       
   359     iControl = CXnNewstickerControl::NewL( this );    
       
   360     iSvgControl = CXnNewstickerSvgControl::NewL( this );
       
   361     
       
   362     iPeriodicTimer = CPeriodic::NewL( CActive::EPriorityStandard );
       
   363     
       
   364     iPowerSaveMode = ETrue;
       
   365     
       
   366     iRestartAfterUpdate = EFalse;
       
   367     SetTextPropertiesL();
       
   368     SetNewstickerPropertiesL();
       
   369     
       
   370     RPointerArray<CXnNodePluginIf> children = iNode.ChildrenL();
       
   371     CleanupClosePushL( children );
       
   372     for( TInt i = 0; i < children.Count(); ++i )
       
   373         {
       
   374         CXnNodePluginIf* child( children[i] );
       
   375         
       
   376         CXnType* xnType = child->Type();
       
   377         // We only care for <title> nodes
       
   378         if ( xnType && xnType->Type() == XnPropertyNames::title::KTitle )
       
   379             {
       
   380             // Append  title, if one is given from the theme use that.
       
   381             // If no content yet available create empty title so that 
       
   382             // indexing is always current
       
   383             const TDesC8& pcData( child->GetPCData() );
       
   384     
       
   385             HBufC* pcData16 = CnvUtfConverter::ConvertToUnicodeFromUtf8L( pcData );
       
   386             CleanupStack::PushL( pcData16 );
       
   387     
       
   388             TPtr ptr( pcData16->Des() );
       
   389     
       
   390             CXnUtils::CollapseWhiteSpace( iNode, ptr );
       
   391     
       
   392             if( ptr.Length() > 0 )
       
   393                 {
       
   394                 iControl->AppendTitleL( *pcData16 );
       
   395                 }
       
   396             else
       
   397                 {
       
   398                 iControl->AppendTitleL( KNullDesC );
       
   399                 }
       
   400     
       
   401             CleanupStack::PopAndDestroy( pcData16 );
       
   402             }
       
   403         }
       
   404     CleanupStack::PopAndDestroy( &children );
       
   405     }
       
   406 
       
   407 // -----------------------------------------------------------------------------
       
   408 // CXnNewstickerAdapter::CXnNewstickerAdapter
       
   409 // C++ default constructor
       
   410 // -----------------------------------------------------------------------------
       
   411 //
       
   412 CXnNewstickerAdapter::CXnNewstickerAdapter(CXnControlAdapter* /*aParent*/, 
       
   413     CXnNodePluginIf& aNode)
       
   414     : iState(ENotStarted), iNode(aNode)
       
   415     {
       
   416     }
       
   417 
       
   418 // -----------------------------------------------------------------------------
       
   419 // CXnNewstickerAdapter::~CXnNewstickerAdapter
       
   420 // C++ destructor
       
   421 // -----------------------------------------------------------------------------
       
   422 //
       
   423 CXnNewstickerAdapter::~CXnNewstickerAdapter()
       
   424     {           
       
   425     if( iPeriodicTimer )
       
   426         {
       
   427         iPeriodicTimer->Cancel();
       
   428         }
       
   429         
       
   430     delete iPeriodicTimer;
       
   431 
       
   432     if( iFont && iReleaseFont )
       
   433         {
       
   434         CWsScreenDevice* dev = iCoeEnv->ScreenDevice();
       
   435         dev->ReleaseFont( iFont ); 
       
   436         }
       
   437         
       
   438     delete iControl;
       
   439     
       
   440     if( iState == EAnimation )
       
   441         {
       
   442         TRAP_IGNORE( iSvgControl->StopL() );
       
   443         }
       
   444         
       
   445     delete iSvgControl;
       
   446     delete iBufferDevice;
       
   447 	delete iDrawingBuffer;
       
   448 	delete iBufferGc;
       
   449     delete iBackgroundBitmap;
       
   450     }
       
   451 
       
   452 // -----------------------------------------------------------------------------
       
   453 // CXnNewstickerAdapter::SetTextPropertiesL
       
   454 // Sets text properties, such as color, font, etc.
       
   455 // -----------------------------------------------------------------------------
       
   456 //
       
   457 void CXnNewstickerAdapter::SetTextPropertiesL()
       
   458     {
       
   459     if (iFont && iReleaseFont)
       
   460         {
       
   461         CWsScreenDevice* dev = iCoeEnv->ScreenDevice();
       
   462         dev->ReleaseFont(iFont); 
       
   463         iFont = NULL;
       
   464         }
       
   465     CXnUtils::CreateFontL(iNode, iFont, iReleaseFont);
       
   466     iControl->SetFont(iFont);
       
   467     
       
   468     TBool colorSet(EFalse);
       
   469     CXnProperty* colorProperty = iNode.GetPropertyL(XnPropertyNames::appearance::common::KColor);
       
   470     if (colorProperty != NULL)
       
   471         {
       
   472         CXnDomProperty* domProperty = colorProperty->Property();
       
   473         if(domProperty)
       
   474             {
       
   475             TRgb textColor;
       
   476             TInt error( KErrNotSupported );
       
   477             CXnDomPropertyValue* value = static_cast< CXnDomPropertyValue* >
       
   478                                             ( domProperty->PropertyValueList().Item( 0 ) );
       
   479             if( value->IsAutoIdent() )
       
   480                 {
       
   481                 MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance();
       
   482                 error = AknsUtils::GetCachedColor(skinInstance, textColor, KAknsIIDQsnTextColors,
       
   483                 EAknsCIQsnTextColorsCG6);
       
   484                 }
       
   485             else if( value->PrimitiveValueType() == CXnDomPropertyValue::ERgbColor )
       
   486                 {
       
   487                 textColor = value->RgbColorValueL();
       
   488                 error = KErrNone;
       
   489                 }
       
   490             else
       
   491                 {
       
   492                 HBufC* colorString = colorProperty->StringValueL();
       
   493                 CleanupStack::PushL( colorString );
       
   494                 
       
   495                 CXnUtils::StripQuotes( colorString );
       
   496                 
       
   497                 TInt index = 0;
       
   498                 TAknsItemID skinID;
       
   499                 
       
   500                 TBool idResolved = CXnUtils::ResolveSkinItemIDL( colorString->Des(), skinID, index );
       
   501                 
       
   502                 if( idResolved )
       
   503                     {
       
   504                     MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance();
       
   505                     error = AknsUtils::GetCachedColor( skinInstance, textColor, skinID, index );
       
   506                     }
       
   507                 else // use auto value if skin id is invalid.
       
   508                     {
       
   509                     MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance();
       
   510                     error = AknsUtils::GetCachedColor(skinInstance, textColor, KAknsIIDQsnTextColors,
       
   511                     EAknsCIQsnTextColorsCG6);
       
   512                     }
       
   513                 CleanupStack::PopAndDestroy( colorString );                 
       
   514                 }
       
   515             if (error == KErrNone)
       
   516                 {
       
   517                 iControl->SetTextColor(textColor);
       
   518                 colorSet = ETrue;
       
   519                 }
       
   520             }
       
   521         }
       
   522 
       
   523     if(!colorSet) // Use text skin color
       
   524         {
       
   525         MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance();
       
   526         TRgb textColor;
       
   527         TInt error = AknsUtils::GetCachedColor( skinInstance, textColor, 
       
   528             KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6);
       
   529         if (error == KErrNone)
       
   530             {
       
   531             iControl->SetTextColor(textColor);
       
   532             }
       
   533         }
       
   534     
       
   535     CXnProperty* textDecorationProp = 
       
   536         iNode.GetPropertyL(XnPropertyNames::appearance::common::KTextDecoration);
       
   537     if(textDecorationProp)
       
   538         {
       
   539         CXnDomList& propertyValueList = textDecorationProp->Property()->PropertyValueList();
       
   540         TInt valueCount = propertyValueList.Length();
       
   541         for (TInt i = 0; i < valueCount; ++i)
       
   542             {
       
   543             CXnDomPropertyValue* value = 
       
   544                 static_cast<CXnDomPropertyValue*>(propertyValueList.Item(i));
       
   545             if (value->StringValueL() == 
       
   546                 XnPropertyNames::appearance::common::textdecoration::KUnderline)
       
   547                 {
       
   548                 iControl->SetTextUnderlineStyle(EUnderlineOn);
       
   549                 }
       
   550             if (value->StringValueL() == 
       
   551                 XnPropertyNames::appearance::common::textdecoration::KLinethrough)
       
   552                 {
       
   553                 iControl->SetTextStrikethroughStyle(EStrikethroughOn);
       
   554                 }
       
   555             }
       
   556         }
       
   557     
       
   558     TGulAlignmentValue alignment = CXnUtils::TextAlignment( iNode );
       
   559     
       
   560     TInt textAlignment( ELayoutAlignLeft ); // all are vertically top aligned by default (avkon)
       
   561     
       
   562     switch( alignment )
       
   563         {
       
   564         case EHCenterVCenter:            
       
   565             textAlignment = ELayoutAlignCenter;                 
       
   566             break;
       
   567         case EHRightVCenter:            
       
   568             textAlignment = ELayoutAlignRight;                
       
   569             break;
       
   570         default: 
       
   571             break;    
       
   572         }
       
   573     
       
   574     iControl->SetTextAlignment(textAlignment);
       
   575     }
       
   576 
       
   577 // ---------------------------------------------------------
       
   578 // CXnNewstickerAdapter::AppendTitleL
       
   579 // ---------------------------------------------------------
       
   580 //
       
   581 void CXnNewstickerAdapter::AppendTitleL(const TDesC& aTitle)
       
   582     {
       
   583     iControl->AppendTitleL(aTitle);
       
   584     iNode.SetDirtyL();
       
   585     }
       
   586 
       
   587 // ---------------------------------------------------------
       
   588 // CXnNewstickerAdapter::InsertTitleL
       
   589 // ---------------------------------------------------------
       
   590 //
       
   591 void CXnNewstickerAdapter::InsertTitleL(const TDesC& aTitle, TInt aIndex)
       
   592     {
       
   593     iControl->InsertTitleL(aTitle, aIndex);
       
   594     iNode.SetDirtyL();
       
   595     }
       
   596 
       
   597 // ---------------------------------------------------------
       
   598 // CXnNewstickerAdapter::UpdateTitleL
       
   599 // ---------------------------------------------------------
       
   600 //
       
   601 void CXnNewstickerAdapter::UpdateTitleL(const TDesC& aTitle, TInt aIndex)
       
   602     {
       
   603     iControl->UpdateTitleL(aTitle, aIndex);
       
   604     iNode.SetDirtyL();
       
   605     if ( iRestartAfterUpdate )
       
   606         {
       
   607         RestartL();
       
   608         }
       
   609     }
       
   610 
       
   611 // ---------------------------------------------------------
       
   612 // CXnNewstickerAdapter::DeleteTitleL
       
   613 // ---------------------------------------------------------
       
   614 //
       
   615 void CXnNewstickerAdapter::DeleteTitleL(TInt aIndex)
       
   616     {
       
   617     if( iState == EAnimation && iControl->CurrentTitleIndex() == aIndex )
       
   618         {
       
   619         //  About to delete the currently showing animation
       
   620         iSvgControl->StopL();
       
   621         iControl->DeleteTitleL( aIndex );
       
   622 
       
   623         RestartL();
       
   624         }
       
   625     else
       
   626         {
       
   627         iControl->DeleteTitleL(aIndex);
       
   628         }
       
   629 
       
   630     iNode.SetDirtyL();
       
   631     }
       
   632 
       
   633 // ---------------------------------------------------------
       
   634 // CXnNewstickerAdapter::CurrentTitleIndex
       
   635 // ---------------------------------------------------------
       
   636 //
       
   637 TInt CXnNewstickerAdapter::CurrentTitleIndex()
       
   638     {
       
   639     return iControl->CurrentTitleIndex();
       
   640     }
       
   641 
       
   642 // ---------------------------------------------------------
       
   643 // CXnNewstickerAdapter::Title
       
   644 // ---------------------------------------------------------
       
   645 //
       
   646 const TDesC& CXnNewstickerAdapter::Title(TInt aIndex)
       
   647     {
       
   648     return iControl->Title(aIndex);
       
   649     }
       
   650 
       
   651 // ---------------------------------------------------------
       
   652 // CXnNewstickerAdapter::SetSeparatorImageL
       
   653 // ---------------------------------------------------------
       
   654 //
       
   655 TInt CXnNewstickerAdapter::SetSeparatorImageL(CGulIcon* aIcon)
       
   656     {
       
   657     return iControl->SetSeparatorImageL(aIcon);
       
   658     }
       
   659 
       
   660 // ---------------------------------------------------------
       
   661 // CXnNewstickerAdapter::ClearTitles
       
   662 // ---------------------------------------------------------
       
   663 //
       
   664 void CXnNewstickerAdapter::ClearTitles()
       
   665     {
       
   666     iControl->ClearTitles();
       
   667     TRAP_IGNORE(iNode.SetDirtyL());
       
   668     }
       
   669 
       
   670 // ---------------------------------------------------------
       
   671 // CXnNewstickerAdapter::AppendSvgTitleL
       
   672 // ---------------------------------------------------------
       
   673 //
       
   674 void CXnNewstickerAdapter::AppendSvgTitleL(const TDesC8& aByteData)
       
   675     {
       
   676     iControl->AppendSvgTitleL(aByteData);
       
   677     }
       
   678 
       
   679 // ---------------------------------------------------------
       
   680 // CXnNewstickerAdapter::InsertSvgTitleL
       
   681 // ---------------------------------------------------------
       
   682 //
       
   683 void CXnNewstickerAdapter::InsertSvgTitleL(const TDesC8& aByteData, TInt aIndex)
       
   684     {
       
   685     iControl->InsertSvgTitleL(aByteData, aIndex);
       
   686     }
       
   687 
       
   688 // ---------------------------------------------------------
       
   689 // CXnNewstickerAdapter::SetCallbackInterfaceL
       
   690 // ---------------------------------------------------------
       
   691 //
       
   692 void CXnNewstickerAdapter::SetCallbackInterfaceL(
       
   693         XnNewstickerInterface::MXnNewstickerCallbackInterface* aCallback)
       
   694     {
       
   695     iCallback = aCallback;
       
   696     }
       
   697 
       
   698 // ---------------------------------------------------------
       
   699 // CXnNewstickerAdapter::TitleScrolled
       
   700 // ---------------------------------------------------------
       
   701 //
       
   702 void CXnNewstickerAdapter::TitleScrolled(TInt aTitleIndex)
       
   703     {
       
   704     if (iCallback)
       
   705         {
       
   706         iCallback->TitleScrolled(aTitleIndex);
       
   707         }
       
   708     // if not looping, see if the last item was scrolled...
       
   709     if( !iControl->ScrollLooping() &&
       
   710          aTitleIndex == iControl->TitleCount() - 1 )
       
   711         {
       
   712         iState = EScrollEnded;
       
   713         TRAP_IGNORE( StopL() );
       
   714         DrawNow();
       
   715         }
       
   716     }
       
   717 
       
   718 // -----------------------------------------------------------------------------
       
   719 // CXnNewstickerAdapter::DrawBackground()
       
   720 // -----------------------------------------------------------------------------
       
   721 //
       
   722 void CXnNewstickerAdapter::DrawBackgroundL(const TRect& aRect, CWindowGc& aGc) const
       
   723     {
       
   724     RPointerArray<CXnControlAdapter> adapters;
       
   725     
       
   726     for ( CXnNodePluginIf* node = &iNode; node; ) 
       
   727         {
       
   728         CXnControlAdapter* adapter( node->Control() );
       
   729         
       
   730         if ( adapter )
       
   731             {
       
   732             adapters.Append( adapter );
       
   733             }
       
   734                         
       
   735         node = node->ParentL();
       
   736         }
       
   737     
       
   738     for ( TInt i = adapters.Count() - 1; i >= 0; --i )
       
   739         {
       
   740         adapters[i]->Draw( aRect, aGc );
       
   741         }
       
   742     
       
   743     adapters.Reset();        
       
   744     }
       
   745 
       
   746 // -----------------------------------------------------------------------------
       
   747 // CXnNewstickerAdapter::SetTimerToDisplaytime()
       
   748 // -----------------------------------------------------------------------------
       
   749 //
       
   750 void CXnNewstickerAdapter::SetTimerToDisplaytime()
       
   751     {
       
   752     if( iCurrentInterval != iAlternateInterval )
       
   753         {
       
   754         iPeriodicTimer->Cancel();
       
   755         
       
   756         iPeriodicTimer->Start(
       
   757             TTimeIntervalMicroSeconds32( iAlternateInterval ),
       
   758             TTimeIntervalMicroSeconds32( iAlternateInterval ), 
       
   759             TCallBack( CXnNewstickerAdapter::PeriodicEventL, this ) );
       
   760         iCurrentInterval = iAlternateInterval;
       
   761         }
       
   762     }
       
   763 
       
   764 // -----------------------------------------------------------------------------
       
   765 // CXnNewstickerAdapter::SetTimerToScrolltime()
       
   766 // -----------------------------------------------------------------------------
       
   767 //
       
   768 void CXnNewstickerAdapter::SetTimerToScrolltime()
       
   769     {
       
   770     if( iCurrentInterval != iInterval )
       
   771         {
       
   772         iPeriodicTimer->Cancel();
       
   773         
       
   774         iPeriodicTimer->Start(
       
   775             TTimeIntervalMicroSeconds32( iInterval ),
       
   776             TTimeIntervalMicroSeconds32( iInterval ), 
       
   777             TCallBack( CXnNewstickerAdapter::PeriodicEventL, this ) );
       
   778         iCurrentInterval = iInterval;
       
   779         }
       
   780     }
       
   781 // ---------------------------------------------------------
       
   782 // CXnNewstickerAdapter::StartL
       
   783 // ---------------------------------------------------------
       
   784 //
       
   785 void CXnNewstickerAdapter::StartL()
       
   786     {
       
   787     if( iDisplay && !iPowerSaveMode )
       
   788         {
       
   789         if( iControl->TitleCount() == 0 )
       
   790             {
       
   791             // Nothing to show
       
   792             return;
       
   793             }
       
   794 
       
   795         if( iPeriodicTimer && !iPeriodicTimer->IsActive() )
       
   796             {
       
   797             TInt startDelay( ( iState == ENotStarted ) ? iDelay : KNoDelay );
       
   798 
       
   799             //  Start
       
   800             if ( ScrollBehaviour() == CXnNewstickerAdapter::EScrollAlternate &&
       
   801                  iControl->CalculateCurrentTextFitInNewstickerRect() )
       
   802                 {
       
   803                 iPeriodicTimer->Start(                
       
   804                     TTimeIntervalMicroSeconds32( startDelay ),
       
   805                     TTimeIntervalMicroSeconds32( iAlternateInterval ), 
       
   806                     TCallBack( CXnNewstickerAdapter::PeriodicEventL, this ) );
       
   807                 iCurrentInterval = iAlternateInterval;
       
   808                 }
       
   809             else
       
   810                 {
       
   811                 iPeriodicTimer->Start(                
       
   812                     TTimeIntervalMicroSeconds32( startDelay ),
       
   813                     TTimeIntervalMicroSeconds32( iInterval ), 
       
   814                     TCallBack( CXnNewstickerAdapter::PeriodicEventL, this ) );
       
   815                 iCurrentInterval = iInterval;
       
   816                 }
       
   817         
       
   818             iState = EText;                       
       
   819             }            
       
   820         }
       
   821     }
       
   822 
       
   823 // ---------------------------------------------------------
       
   824 // CXnNewstickerAdapter::StopL
       
   825 // ---------------------------------------------------------
       
   826 //
       
   827 void CXnNewstickerAdapter::StopL()
       
   828     {
       
   829     if( iState == EAnimation )
       
   830         {
       
   831         iSvgControl->StopL();
       
   832         }
       
   833 
       
   834     //  Have we already been started
       
   835     if( iPeriodicTimer->IsActive() )
       
   836         {
       
   837         //  Yes, cancel and set the state
       
   838        iPeriodicTimer->Cancel();
       
   839        
       
   840        if ( iState == EScrollEnded )
       
   841            {
       
   842            iControl->MoveToLastL();
       
   843            iControl->DrawStatic();
       
   844            }
       
   845        else if ( iState == EText || iState == EAnimation )
       
   846            {
       
   847            iState = EPaused;
       
   848            }
       
   849         }
       
   850     // Entering power save mode => Move to last item and draw it
       
   851     if ( ( iScrollBehaviour == EAlternate ||
       
   852           iScrollBehaviour == EScrollAlternate )
       
   853         && iPowerSaveMode )
       
   854        {
       
   855        iState = EPaused;
       
   856        iControl->MoveToLastL();
       
   857        iControl->DrawStatic();
       
   858        }        
       
   859     }
       
   860 
       
   861 // ---------------------------------------------------------
       
   862 // CXnNewstickerAdapter::ShowSvgL
       
   863 // ---------------------------------------------------------
       
   864 //
       
   865 void CXnNewstickerAdapter::ShowSvgL()
       
   866     {
       
   867     //  Get next animation from model and start it
       
   868     iSvgControl->StartL( iControl->CurrentSvgTitle() );
       
   869 
       
   870     //  Set the end timer
       
   871     iState = EAnimation;
       
   872     
       
   873     iPeriodicTimer->Cancel();
       
   874     
       
   875     iPeriodicTimer->Start(
       
   876         TTimeIntervalMicroSeconds32( iAnimationTime ),
       
   877         TTimeIntervalMicroSeconds32( iAnimationTime ), 
       
   878         TCallBack( CXnNewstickerAdapter::PeriodicEventL, this ) );
       
   879     iCurrentInterval = iAnimationTime;
       
   880     }
       
   881 
       
   882 // ---------------------------------------------------------
       
   883 // CXnNewstickerAdapter::PeriodicEventL
       
   884 // ---------------------------------------------------------
       
   885 //
       
   886 TInt CXnNewstickerAdapter::PeriodicEventL( TAny* aPtr )
       
   887     {
       
   888     CXnNewstickerAdapter* self = static_cast< CXnNewstickerAdapter* >( aPtr );
       
   889     
       
   890     if( self->iState == EText )
       
   891         {
       
   892         //  Do the text scroll
       
   893         self->iControl->DoScrollL();
       
   894         }
       
   895     else if( self->iState == EAnimation )
       
   896         {
       
   897         self->iSvgControl->StopL();
       
   898         self->TitleScrolled( self->iControl->CurrentTitleIndex() );
       
   899         //  Animation scroll has been ended, start the next scroll
       
   900         self->iState = ENotStarted;
       
   901         self->iPeriodicTimer->Cancel();
       
   902         self->StartL();
       
   903         //  Do the first draw
       
   904         self->iControl->SetBeginningState();
       
   905         self->iControl->DoScrollL();
       
   906         }
       
   907 
       
   908     return KErrNone;
       
   909     }
       
   910 
       
   911 void CXnNewstickerAdapter::RestartL()
       
   912     {
       
   913     if ( iPowerSaveMode )
       
   914         {
       
   915         return;
       
   916         }
       
   917     //  Restart
       
   918      iState = ENotStarted;
       
   919      iPeriodicTimer->Cancel();
       
   920      
       
   921      iControl->MoveToFirstL();
       
   922      StartL();
       
   923      
       
   924      //  Do the first draw
       
   925      iControl->SetBeginningState();
       
   926     }
       
   927 // ---------------------------------------------------------
       
   928 // CXnNewstickerAdapter::SizeChanged()
       
   929 // ---------------------------------------------------------
       
   930 //
       
   931 void CXnNewstickerAdapter::SizeChanged()
       
   932     {
       
   933     CXnControlAdapter::SizeChanged();
       
   934     TRAP_IGNORE( SizeChangedL() );
       
   935     }
       
   936 
       
   937 // ---------------------------------------------------------
       
   938 // CXnNewstickerAdapter::SizeChangedL()
       
   939 // ---------------------------------------------------------
       
   940 //
       
   941 void CXnNewstickerAdapter::SizeChangedL()
       
   942     {        
       
   943     UpdateDoubleBufferL();
       
   944 
       
   945     TRect rect( Rect() );            
       
   946             
       
   947     iControl->SetNewstickerRect( rect );
       
   948     iSvgControl->SetSvgRectL( rect, *SystemGc().Device() );
       
   949     }
       
   950 
       
   951 // -----------------------------------------------------------------------------
       
   952 // CXnNewstickerAdapter::HandlePointerEventL
       
   953 // -----------------------------------------------------------------------------
       
   954 // 
       
   955 void CXnNewstickerAdapter::HandlePointerEventL(const TPointerEvent& aPointerEvent)
       
   956     {
       
   957 	if ( AknLayoutUtils::PenEnabled() )
       
   958 	    {
       
   959         CXnControlAdapter::HandlePointerEventL(aPointerEvent);
       
   960         }
       
   961     }
       
   962 // -----------------------------------------------------------------------------
       
   963 // CXnNewstickerAdapter::DoHandlePropertyChangeL
       
   964 // -----------------------------------------------------------------------------
       
   965 //
       
   966 void CXnNewstickerAdapter::DoHandlePropertyChangeL( CXnProperty* aProperty )
       
   967     {
       
   968     SetTextPropertiesL();
       
   969     SetNewstickerPropertiesL();
       
   970     //New code to check do we need Start or Stop Newsticker
       
   971     if( aProperty )
       
   972         {
       
   973         const TDesC8& name( aProperty->Property()->Name() );
       
   974                
       
   975         if( name == XnPropertyNames::style::common::KDisplay ||
       
   976         	name == XnPropertyNames::style::common::KVisibility )
       
   977         	{               
       
   978             if( CheckDisplayL( iNode ) )
       
   979                 {
       
   980                 StartL();
       
   981                 }
       
   982             else
       
   983                 {
       
   984                 StopL();
       
   985                 }                   
       
   986         	}
       
   987         }
       
   988     }
       
   989     	
       
   990 // -----------------------------------------------------------------------------
       
   991 // CXnNewstickerAdapter::FocusChanged
       
   992 // -----------------------------------------------------------------------------
       
   993 // 
       
   994 void CXnNewstickerAdapter::FocusChanged(TDrawNow /*aDrawNow*/) 
       
   995     {
       
   996     }
       
   997 
       
   998 // -----------------------------------------------------------------------------
       
   999 // CXnNewstickerAdapter::SkinChanged
       
  1000 // -----------------------------------------------------------------------------
       
  1001 // 
       
  1002 void CXnNewstickerAdapter::SkinChanged() 
       
  1003     {
       
  1004     CXnControlAdapter::SkinChanged();
       
  1005     TRAP_IGNORE( SetTextPropertiesL() );
       
  1006     }
       
  1007 
       
  1008 void CXnNewstickerAdapter::ReportNewstickerEventL(const TDesC8& aEventName)
       
  1009     { 
       
  1010     TBuf8<8>index(KNullDesC8);
       
  1011     index.Num(CurrentTitleIndex());
       
  1012     
       
  1013     iNode.ReportTriggerEventL(aEventName,
       
  1014             XnPropertyNames::action::trigger::name::KTitleIndex, index);
       
  1015     }
       
  1016 // -----------------------------------------------------------------------------
       
  1017 // CXnNewstickerAdapter::OfferKeyEventL
       
  1018 // -----------------------------------------------------------------------------
       
  1019 // 
       
  1020 TKeyResponse CXnNewstickerAdapter::OfferKeyEventL(
       
  1021         const TKeyEvent& aKeyEvent, TEventCode aType)
       
  1022     {
       
  1023     TKeyResponse    resp = EKeyWasNotConsumed;
       
  1024     TBool           restart = EFalse;
       
  1025 
       
  1026     CXnControlAdapter::OfferKeyEventL(aKeyEvent, aType);
       
  1027 
       
  1028     if(aType == EEventKey)
       
  1029         {
       
  1030         if (aKeyEvent.iScanCode == EStdKeyRightArrow)
       
  1031             {
       
  1032             restart = ETrue;
       
  1033             if(iControl->IsWestern())
       
  1034                 {
       
  1035                 iControl->MoveToNextL();
       
  1036                 }
       
  1037             else
       
  1038                 {
       
  1039                 iControl->MoveToPrevL();
       
  1040                 }
       
  1041             StopL();
       
  1042             }
       
  1043         else if (aKeyEvent.iScanCode == EStdKeyLeftArrow)
       
  1044             {
       
  1045             restart = ETrue;
       
  1046             if(iControl->IsWestern())
       
  1047                 {
       
  1048                 iControl->MoveToPrevL();
       
  1049                 }
       
  1050             else
       
  1051                 {
       
  1052                 iControl->MoveToNextL();
       
  1053                 }
       
  1054             StopL();
       
  1055             }
       
  1056         }
       
  1057     if(aType == EEventKeyUp)
       
  1058         {
       
  1059         if (aKeyEvent.iScanCode == EStdKeyDevice3) // rocker
       
  1060             {
       
  1061             restart = ETrue;
       
  1062             StopL();
       
  1063             iControl->MoveToCurrent();            
       
  1064             }
       
  1065         }
       
  1066         
       
  1067     if( restart )
       
  1068         {
       
  1069         //  Restart and do the first draw
       
  1070         iState = ENotStarted;
       
  1071         StartL();
       
  1072         iControl->DoScrollL();
       
  1073         }
       
  1074         
       
  1075     return resp;
       
  1076     }
       
  1077 
       
  1078 // -----------------------------------------------------------------------------
       
  1079 // CXnNewstickerAdapter::Draw
       
  1080 // Draws the text component
       
  1081 // -----------------------------------------------------------------------------
       
  1082 void CXnNewstickerAdapter::Draw(const TRect& aRect) const
       
  1083     {
       
  1084     CXnControlAdapter::Draw( aRect );
       
  1085             
       
  1086     TRAP_IGNORE( UpdateBackgroundL() );
       
  1087     // In powersave-/editmode only draw the last title. 
       
  1088     if ( iScrollBehaviour == EAlternate && iPowerSaveMode )
       
  1089         {
       
  1090         iControl->DrawStatic();
       
  1091         
       
  1092         // Blit double buffer
       
  1093         SystemGc().BitBlt( Rect().iTl, iDrawingBuffer );    
       
  1094         }
       
  1095     else if( iState == EText || iState == EPaused && 
       
  1096             iControl->CurrentTitleIndex() >= 0 )
       
  1097         {
       
  1098         iControl->Draw();
       
  1099 
       
  1100         // Blit double buffer
       
  1101         SystemGc().BitBlt( Rect().iTl, iDrawingBuffer );                
       
  1102         }
       
  1103     else if( iState == EAnimation )
       
  1104         {                            
       
  1105         iSvgControl->Draw();
       
  1106         
       
  1107         // Blit double buffer
       
  1108         SystemGc().BitBlt( Rect().iTl, iDrawingBuffer );            
       
  1109         }
       
  1110     else if( iState == EScrollEnded )
       
  1111         {
       
  1112         iControl->DrawStatic();
       
  1113         SystemGc().BitBlt( Rect().iTl, iDrawingBuffer );
       
  1114         }
       
  1115     }
       
  1116     
       
  1117 // -----------------------------------------------------------------------------
       
  1118 // CXnNewstickerAdapter::UpdateDoubleBufferL
       
  1119 // -----------------------------------------------------------------------------
       
  1120 //
       
  1121 void CXnNewstickerAdapter::UpdateDoubleBufferL()
       
  1122     {
       
  1123 	TDisplayMode displayMode( SystemGc().Device()->DisplayMode() );
       
  1124 	
       
  1125     // Create double buffer
       
  1126     if( iDrawingBuffer ) 
       
  1127         {
       
  1128         delete iDrawingBuffer;
       
  1129         iDrawingBuffer = NULL;
       
  1130         delete iBufferDevice;
       
  1131         iBufferDevice = NULL;
       
  1132         delete iBufferGc;
       
  1133         iBufferGc = NULL;        
       
  1134         }
       
  1135         
       
  1136 	iDrawingBuffer = new ( ELeave ) CFbsBitmap();
       
  1137 	iDrawingBuffer->Create( iNode.Rect().Size(), displayMode );
       
  1138     iBufferDevice = CFbsBitmapDevice::NewL( iDrawingBuffer );
       
  1139     iBufferDevice->CreateBitmapContext( iBufferGc );
       
  1140     iBufferGc->UseFont( iControl->Font() );
       
  1141     iBufferGc->SetPenColor( iControl->TextColor() );
       
  1142     iBufferGc->SetStrikethroughStyle( iControl->TextStrikethroughStyle() );
       
  1143     iBufferGc->SetUnderlineStyle( iControl->TextUnderlineStyle() );
       
  1144     }
       
  1145 
       
  1146 // -----------------------------------------------------------------------------
       
  1147 // CXnNewstickerAdapter::UpdateBackgroundL
       
  1148 // -----------------------------------------------------------------------------
       
  1149 //
       
  1150 void CXnNewstickerAdapter::UpdateBackgroundL() const
       
  1151     {
       
  1152     TDisplayMode displayMode( SystemGc().Device()->DisplayMode() );
       
  1153     
       
  1154     // Create "screenshot" from the background appearance
       
  1155     if( iBackgroundBitmap )
       
  1156         {
       
  1157         delete iBackgroundBitmap;
       
  1158         iBackgroundBitmap = NULL;        
       
  1159         }
       
  1160     
       
  1161     iBackgroundBitmap = new ( ELeave ) CFbsBitmap();
       
  1162 	iBackgroundBitmap->Create( iNode.Rect().Size(), displayMode );
       
  1163 	
       
  1164 	CFbsBitmap* tmpBitmap = new ( ELeave ) CFbsBitmap();
       
  1165 	CleanupStack::PushL( tmpBitmap );
       
  1166 	
       
  1167 	CWsScreenDevice* scrDevice = static_cast< CWsScreenDevice* >( SystemGc().Device() );
       
  1168     
       
  1169     TSize tmpSize( scrDevice->SizeInPixels() );
       
  1170     
       
  1171 	tmpBitmap->Create( tmpSize, displayMode );
       
  1172 	
       
  1173     CFbsBitmapDevice* tmpDevice = CFbsBitmapDevice::NewL( tmpBitmap );
       
  1174 	CleanupStack::PushL( tmpDevice );
       
  1175     
       
  1176     CBitmapContext* bc( NULL );
       
  1177     
       
  1178     tmpDevice->CreateBitmapContext( bc );    
       
  1179     CleanupStack::PushL( bc );
       
  1180     
       
  1181     DrawBackgroundL( iNode.Rect(), reinterpret_cast< CWindowGc& >( *bc ) );
       
  1182     
       
  1183     CopyBitmapData( *iBackgroundBitmap, *tmpBitmap, iNode.Rect().iTl );
       
  1184     
       
  1185     CleanupStack::PopAndDestroy( 3 );
       
  1186     }
       
  1187     
       
  1188 // -----------------------------------------------------------------------------
       
  1189 // CXnNewstickerAdapter::DoEnterPowerSaveModeL
       
  1190 // Enter power save mode
       
  1191 // -----------------------------------------------------------------------------
       
  1192 void CXnNewstickerAdapter::DoEnterPowerSaveModeL(TModeEvent /*aEvent*/)
       
  1193     {
       
  1194     iDisplay = EFalse;        
       
  1195     iPowerSaveMode = ETrue;
       
  1196         
       
  1197     StopL();
       
  1198     }
       
  1199 
       
  1200 // -----------------------------------------------------------------------------
       
  1201 // CXnNewstickerAdapter::DoExitPowerSaveModeL
       
  1202 // Exit power save mode
       
  1203 // -----------------------------------------------------------------------------
       
  1204 void CXnNewstickerAdapter::DoExitPowerSaveModeL(TModeEvent /*aEvent*/)
       
  1205     {
       
  1206     iPowerSaveMode = EFalse;
       
  1207             
       
  1208     if( CheckDisplayL( iNode ) )
       
  1209         {
       
  1210         RestartL();
       
  1211         
       
  1212         if( iDrawingBuffer )
       
  1213             {
       
  1214             DrawNow(); 
       
  1215             }
       
  1216         }
       
  1217     }
       
  1218 
       
  1219 // -----------------------------------------------------------------------------
       
  1220 // CXnNewstickerAdapter::DrawNow
       
  1221 // Draw
       
  1222 // -----------------------------------------------------------------------------
       
  1223 void CXnNewstickerAdapter::DrawNow() const
       
  1224     {
       
  1225     TBool parentDrawn = EFalse;
       
  1226     TRAP_IGNORE( parentDrawn = DrawFocusableParentL() );
       
  1227     if ( !parentDrawn )
       
  1228         {
       
  1229         CCoeControl::DrawNow();
       
  1230         }
       
  1231     }
       
  1232 
       
  1233 // -----------------------------------------------------------------------------
       
  1234 // CXnNewstickerAdapter::DrawFocusableParentL
       
  1235 // Draws focusable parent
       
  1236 // -----------------------------------------------------------------------------
       
  1237 TBool CXnNewstickerAdapter::DrawFocusableParentL() const
       
  1238     {
       
  1239     TBool parentDrawn = EFalse;
       
  1240     
       
  1241     if ( !iNode.IsFocusedState() )
       
  1242         {
       
  1243         // node is not focusable, find focusable and focused parent
       
  1244         CXnNodePluginIf* parent = iNode.ParentL();
       
  1245         while ( parent && !parent->IsFocusedState() )
       
  1246             {
       
  1247             parent = parent->ParentL();
       
  1248             }
       
  1249         
       
  1250         if (parent)
       
  1251             {
       
  1252             // focusable parent found, draw it
       
  1253             parent->Control()->DrawNow();
       
  1254             parentDrawn = ETrue;
       
  1255             }
       
  1256         }
       
  1257     
       
  1258     return parentDrawn;
       
  1259     }
       
  1260 
       
  1261 // End of file