mobilemessaging/smilui/playersrc/SmilPlayerPresentationControl.cpp
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 2004,2005 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: SmilPlayerPresentationControl implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <eikenv.h>
       
    21 
       
    22 #include "SmilPlayerPresentationControl.h"
       
    23 #include "SmilPlayerPresentationController.h"
       
    24 
       
    25 // ============================ MEMBER FUNCTIONS ===============================
       
    26 
       
    27 // ----------------------------------------------------------------------------
       
    28 // CSmilPlayerPresentationControl::CSmilPlayerPresentationControl
       
    29 // C++ constructor 
       
    30 // ----------------------------------------------------------------------------
       
    31 //
       
    32 CSmilPlayerPresentationControl::CSmilPlayerPresentationControl(
       
    33                                 CSmilPlayerPresentationController* aParent ) :
       
    34     iParent( aParent )
       
    35     {
       
    36     }
       
    37 
       
    38 // ----------------------------------------------------------------------------
       
    39 // CSmilPlayerPresentationControl::ConstructL
       
    40 // Symbian 2nd phase constructor. Creates timer.
       
    41 // ----------------------------------------------------------------------------
       
    42 //
       
    43 void CSmilPlayerPresentationControl::ConstructL()
       
    44     {
       
    45     SetContainerWindowL( *iParent );
       
    46     MakeVisible( ETrue );
       
    47     }
       
    48 
       
    49 // ----------------------------------------------------------------------------
       
    50 // CSmilPlayerPresentationControl::NewL
       
    51 // Symbian two phased constructor
       
    52 // ----------------------------------------------------------------------------
       
    53 //    
       
    54 CSmilPlayerPresentationControl*
       
    55 CSmilPlayerPresentationControl::NewL( CSmilPlayerPresentationController* aParent )
       
    56     {
       
    57     CSmilPlayerPresentationControl* self = 
       
    58             new(ELeave) CSmilPlayerPresentationControl( aParent );
       
    59 
       
    60     CleanupStack::PushL( self );
       
    61     self->ConstructL();
       
    62     CleanupStack::Pop( self );
       
    63 
       
    64     return self;
       
    65     }
       
    66 
       
    67 // ----------------------------------------------------------------------------
       
    68 // CSmilPlayerPresentationControl::~CSmilPlayerPresentation
       
    69 // Destructor
       
    70 // ----------------------------------------------------------------------------
       
    71 //
       
    72 CSmilPlayerPresentationControl::~CSmilPlayerPresentationControl()
       
    73     {
       
    74     iParent = NULL; // For LINT;
       
    75     }
       
    76 
       
    77 // ----------------------------------------------------------------------------
       
    78 // CSmilPlayerPresentationControl::Draw
       
    79 // Draws the presentation if parsed. Draw area coordinates are adjusted for SMIL
       
    80 // engine to start from 0,0 before SMIL engine is asked to draw the presentation
       
    81 // to bitmap buffer. When bitmap buffer is drawn to the screen only specified
       
    82 // rectangle is drawn to the specified position.
       
    83 // ----------------------------------------------------------------------------
       
    84 //
       
    85 void CSmilPlayerPresentationControl::Draw( const TRect& aRect ) const
       
    86     {
       
    87     TRect presRect( aRect );
       
    88     presRect.Move( -Rect().iTl );
       
    89     
       
    90     DoDrawPresentation( aRect.iTl, presRect, presRect );
       
    91     }
       
    92 
       
    93 // ----------------------------------------------------------------------------
       
    94 // CSmilPlayerPresentationControl::RedrawArea
       
    95 // Invalidates the appropriate window area. Given area comes from SMIL engine
       
    96 // and must be converted from SMIL engine internal coordinates ( where presentation
       
    97 // starts always from 0,0 ) to presentation control coordinates ( that might lay
       
    98 // anywhere within the window).
       
    99 // ----------------------------------------------------------------------------
       
   100 //
       
   101 void CSmilPlayerPresentationControl::RedrawArea( const TRect& aArea ) const
       
   102     {
       
   103     TRect controlRect( aArea );
       
   104     controlRect.Move( Rect().iTl );
       
   105     Window().Invalidate( controlRect );
       
   106     }
       
   107 
       
   108 // ----------------------------------------------------------------------------
       
   109 // CSmilPlayerPresentationControl::DoDrawPresentation
       
   110 // Performs presentation drawing. First SMIL Engine is asked to draw given presentation
       
   111 // area to presentation controller double buffer and after that double buffer is drawn
       
   112 // to screen. This prevent flickering.
       
   113 // ----------------------------------------------------------------------------
       
   114 //
       
   115 void CSmilPlayerPresentationControl::DoDrawPresentation( const TPoint& aDestination,
       
   116                                                          const TRect& aSourceRect,
       
   117                                                          const TRect& aPresentationRect ) const
       
   118     {
       
   119     SystemGc().SetClippingRect( Rect() );
       
   120     
       
   121     CFbsBitGc* buffercontext = iParent->BufferContext();
       
   122     buffercontext->Reset();
       
   123     
       
   124     CSmilPresentation* pres = iParent->Presentation();
       
   125     if ( pres )
       
   126         {
       
   127         if ( pres->IsTransparent() )
       
   128             {
       
   129             //needed to draw white background for transparent objects text)
       
   130             buffercontext->SetPenStyle( CGraphicsContext::ENullPen );
       
   131             buffercontext->SetBrushStyle( CGraphicsContext::ESolidBrush );
       
   132             buffercontext->SetBrushColor( KRgbWhite );
       
   133             buffercontext->DrawRect( aPresentationRect );
       
   134             }
       
   135         
       
   136         pres->Draw( *buffercontext, aPresentationRect );
       
   137         }
       
   138     
       
   139     SystemGc().BitBlt( aDestination, iParent->BufferBitmap(), aSourceRect );  
       
   140     
       
   141     SystemGc().CancelClippingRect();
       
   142     }
       
   143 
       
   144 // End of File