idlehomescreen/xmluirendering/renderingplugins/xnnewstickerfactory/src/xnnewstickersvgcontrol.cpp
changeset 2 08c6ee43b396
parent 1 5315654608de
child 3 fb3763350a08
equal deleted inserted replaced
1:5315654608de 2:08c6ee43b396
     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:  Text scrolling functionality.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <SVGEngineInterfaceImpl.h>
       
    21 
       
    22 #include "xnnewstickersvgcontrol.h"
       
    23 #include "xnnewstickeradapter.h"
       
    24 
       
    25    
       
    26 // ============================ MEMBER FUNCTIONS ===============================
       
    27 
       
    28 // -----------------------------------------------------------------------------
       
    29 // CXnNewstickerSvgControl::CXnNewstickerSvgControl
       
    30 // C++ default constructor can NOT contain any code, that
       
    31 // might leave.
       
    32 // -----------------------------------------------------------------------------
       
    33 //
       
    34 CXnNewstickerSvgControl::CXnNewstickerSvgControl(CXnNewstickerAdapter* aAdapter) :
       
    35     iAdapter(aAdapter)
       
    36     {
       
    37     }
       
    38 
       
    39 // -----------------------------------------------------------------------------
       
    40 // CXnNewstickerSvgControl::ConstructL
       
    41 // Symbian 2nd phase constructor can leave.
       
    42 // -----------------------------------------------------------------------------
       
    43 //
       
    44 void CXnNewstickerSvgControl::ConstructL()
       
    45     {
       
    46     }
       
    47 
       
    48 // -----------------------------------------------------------------------------
       
    49 // CXnNewstickerSvgControl::NewL
       
    50 // Two-phased constructor.
       
    51 // -----------------------------------------------------------------------------
       
    52 //
       
    53 CXnNewstickerSvgControl* CXnNewstickerSvgControl::NewL(CXnNewstickerAdapter* aAdapter)
       
    54     {
       
    55     CXnNewstickerSvgControl* self = new(ELeave)CXnNewstickerSvgControl(aAdapter);
       
    56     CleanupStack::PushL(self);
       
    57     self->ConstructL();
       
    58     CleanupStack::Pop();    
       
    59     return self;
       
    60     }
       
    61 
       
    62 // -----------------------------------------------------------------------------
       
    63 // CXnNewstickerSvgControl::~CXnNewstickerSvgControl()
       
    64 // Destructor.
       
    65 // -----------------------------------------------------------------------------
       
    66 //
       
    67 CXnNewstickerSvgControl::~CXnNewstickerSvgControl()
       
    68     {
       
    69     delete iBitmap;
       
    70 	delete iMaskBitmap;
       
    71 	if(iSVGEngine)
       
    72 	    {
       
    73 	    iSVGEngine->Destroy();
       
    74 		delete iSVGEngine;
       
    75 	    }
       
    76     }
       
    77 
       
    78 // ---------------------------------------------------------
       
    79 // CXnNewstickerSvgControl::StartL
       
    80 // ---------------------------------------------------------
       
    81 //
       
    82 void CXnNewstickerSvgControl::StartL(const TDesC8& aSvgData)
       
    83     {
       
    84     iHasContent = ETrue;
       
    85     if(!iSVGEngine)
       
    86         {        
       
    87     	TFontSpec fspec;
       
    88     	iSVGEngine = CSvgEngineInterfaceImpl::NewL(iBitmap,this, fspec);
       
    89 	    }
       
    90 
       
    91 	MSvgError* error = iSVGEngine->Load(aSvgData);
       
    92 	User::LeaveIfError(error->SystemErrorCode());
       
    93 
       
    94 	// Get the size of the bitmap and set the SVG size to match
       
    95  	TSize tmpsize = iBitmap->SizeInPixels();
       
    96  	iSVGEngine->SetSvgDimensionToFrameBuffer(tmpsize.iWidth, tmpsize.iHeight);
       
    97     iSVGEngine->SetBackgroundColor(0x00FFFFFF, NULL);
       
    98 	iSVGEngine->Start();
       
    99     }
       
   100 
       
   101 // ---------------------------------------------------------
       
   102 // CXnNewstickerSvgControl::StopL
       
   103 // ---------------------------------------------------------
       
   104 //
       
   105 void CXnNewstickerSvgControl::StopL()
       
   106     {
       
   107     iHasContent = EFalse;
       
   108     if(iSVGEngine)
       
   109 	    {
       
   110 		iSVGEngine->Stop();
       
   111 	    }
       
   112     }
       
   113 
       
   114 // -----------------------------------------------------------------------------
       
   115 // CXnNewstickerSvgControl::SetSvgRectL
       
   116 // Set visible rect.
       
   117 // (other items were commented in a header).
       
   118 // -----------------------------------------------------------------------------
       
   119 //
       
   120 void CXnNewstickerSvgControl::SetSvgRectL(TRect& aContentRect, CGraphicsDevice& aDevice )
       
   121     {
       
   122     iContentRect = aContentRect;    
       
   123 	
       
   124 	TDisplayMode displayMode = aDevice.DisplayMode();
       
   125     
       
   126     if(iBitmap)
       
   127         {
       
   128         delete iBitmap;
       
   129         iBitmap = NULL;
       
   130         }
       
   131     iBitmap = new (ELeave) CFbsBitmap();
       
   132  	iBitmap->Create(iContentRect.Size(),displayMode);
       
   133 
       
   134     if(iMaskBitmap)
       
   135         {
       
   136         delete iMaskBitmap;
       
   137         iMaskBitmap = NULL;
       
   138         }
       
   139     iMaskBitmap = new (ELeave) CFbsBitmap();
       
   140  	iMaskBitmap->Create(iContentRect.Size(),EGray256);
       
   141  	
       
   142  	if(iSVGEngine && iHasContent)
       
   143         {
       
   144         iSVGEngine->SetFrameBuffer(iBitmap);
       
   145     	TSize tmpsize = iBitmap->SizeInPixels();
       
   146     	iSVGEngine->SetSvgDimensionToFrameBuffer(tmpsize.iWidth, tmpsize.iHeight);
       
   147         }
       
   148     }
       
   149  
       
   150 // -----------------------------------------------------------------------------
       
   151 // CXnNewstickerSvgControl::Draw
       
   152 // (other items were commented in a header).
       
   153 // -----------------------------------------------------------------------------
       
   154 //
       
   155 void CXnNewstickerSvgControl::Draw() const
       
   156     {       
       
   157     TPoint point(iContentRect.iTl);
       
   158     iAdapter->BufferGc()->BitBlt(TPoint(0,0), iAdapter->BackgroundBitmap());
       
   159     iAdapter->BufferGc()->BitBltMasked(TPoint(0,0), iBitmap, 
       
   160         TRect(iBitmap->SizeInPixels()), iMaskBitmap, ETrue);   
       
   161     }
       
   162 
       
   163 // ---------------------------------------------------------------------------
       
   164 // From class MSvgRequestObserver.
       
   165 // CXnNewstickerSvgControl::UpdateScreen
       
   166 // ---------------------------------------------------------------------------
       
   167 //
       
   168 void CXnNewstickerSvgControl::UpdateScreen()
       
   169     {
       
   170 	iSVGEngine->GenerateMask(iMaskBitmap, NULL);
       
   171     
       
   172     iAdapter->DrawNow();
       
   173     }
       
   174 
       
   175 // ---------------------------------------------------------------------------
       
   176 // From class MSvgRequestObserver.
       
   177 // CXnNewstickerSvgControl::ScriptCall
       
   178 // ---------------------------------------------------------------------------
       
   179 //
       
   180 TBool  CXnNewstickerSvgControl::ScriptCall(
       
   181     const TDesC& /*aScript*/,
       
   182     CSvgElementImpl* /*aCallerElement*/)
       
   183     {
       
   184 	return EFalse;
       
   185     }
       
   186 
       
   187 // ---------------------------------------------------------------------------
       
   188 // From class MSvgRequestObserver.
       
   189 // CXnNewstickerSvgControl::FetchImage
       
   190 // ---------------------------------------------------------------------------
       
   191 //
       
   192 TInt CXnNewstickerSvgControl::FetchImage(
       
   193     const TDesC& /*aUri*/,
       
   194     RFs& /*aSession*/,
       
   195     RFile& /*aFileHandle*/)
       
   196     {
       
   197 	return KErrNotFound;
       
   198     }
       
   199 
       
   200 // ---------------------------------------------------------------------------
       
   201 // From class MSvgRequestObserver.
       
   202 // CXnNewstickerSvgControl::FetchFont
       
   203 // ---------------------------------------------------------------------------
       
   204 //
       
   205 TInt CXnNewstickerSvgControl::FetchFont(
       
   206     const TDesC& /*aUri*/,
       
   207     RFs& /*aSession*/,
       
   208     RFile& /*aFileHandle*/)
       
   209     {
       
   210 	return KErrNotFound;
       
   211     }
       
   212 
       
   213 // ---------------------------------------------------------------------------
       
   214 // From class MSvgRequestObserver.
       
   215 // CXnNewstickerSvgControl::UpdatePresentation
       
   216 // ---------------------------------------------------------------------------
       
   217 //
       
   218 void CXnNewstickerSvgControl::UpdatePresentation(const TInt32&  /*aNoOfAnimation*/)
       
   219     {
       
   220     }
       
   221 
       
   222 //  End of File