gstreamer_test_apps/gstplayer/src/GSTPlayerappview.cpp
branchRCL_3
changeset 30 7e817e7e631c
parent 29 567bb019e3e3
equal deleted inserted replaced
29:567bb019e3e3 30:7e817e7e631c
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
       
     3 *
       
     4 * This library is free software; you can redistribute it and/or
       
     5 * modify it under the terms of the GNU Lesser General Public
       
     6 * License as published by the Free Software Foundation; either
       
     7 * version 2 of the License, or (at your option) any later version.
       
     8 *
       
     9 * This library is distributed in the hope that it will be useful,
       
    10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       
    12 * Lesser General Public License for more details.
       
    13 *
       
    14 * You should have received a copy of the GNU Lesser General Public
       
    15 * License along with this library; if not, write to the
       
    16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
       
    17 * Boston, MA 02111-1307, USA.
       
    18 *
       
    19 * Description:
       
    20 *
       
    21 */
       
    22 /*
       
    23 * ==============================================================================
       
    24 *  Name        : GSTPlayerappview.cpp
       
    25 *  Part of     : GSTPlayer
       
    26 *  Interface   : 
       
    27 *  Description : 
       
    28 *  Version     : 
       
    29 *
       
    30 
       
    31 * ==============================================================================
       
    32 */
       
    33 
       
    34 // INCLUDE FILES
       
    35 #include <coemain.h>
       
    36 #include <stdlib.h>
       
    37 #include <gst/gst.h>
       
    38 #include "gstplayerappview.h"
       
    39 #include "GlibEventHandler.h"
       
    40 
       
    41 // ============================ MEMBER FUNCTIONS ===============================
       
    42 
       
    43 // -----------------------------------------------------------------------------
       
    44 // CGSTPlayerAppView::NewL()
       
    45 // Two-phased constructor.
       
    46 // -----------------------------------------------------------------------------
       
    47 //
       
    48 CGSTPlayerAppView* CGSTPlayerAppView::NewL( const TRect& aRect )
       
    49     {
       
    50     CGSTPlayerAppView* self = CGSTPlayerAppView::NewLC( aRect );
       
    51     CleanupStack::Pop( self );
       
    52     return self;
       
    53     }
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 // CGSTPlayerAppView::NewLC()
       
    57 // Two-phased constructor.
       
    58 // -----------------------------------------------------------------------------
       
    59 //
       
    60 CGSTPlayerAppView* CGSTPlayerAppView::NewLC( const TRect& aRect )
       
    61     {
       
    62     CGSTPlayerAppView* self = new ( ELeave ) CGSTPlayerAppView;
       
    63     CleanupStack::PushL( self );
       
    64     self->ConstructL( aRect );
       
    65     return self;
       
    66     }
       
    67 
       
    68 // -----------------------------------------------------------------------------
       
    69 // CGSTPlayerAppView::ConstructL()
       
    70 // Symbian 2nd phase constructor can leave.
       
    71 // -----------------------------------------------------------------------------
       
    72 //
       
    73 void CGSTPlayerAppView::ConstructL( const TRect& aRect )
       
    74     {
       
    75     // Create a window for this application view
       
    76     CreateWindowL();
       
    77     iRte = CRichTextEditorRTE::NewL(*this);
       
    78     // Set the windows size
       
    79     SetRect( aRect );    
       
    80     // Activate the window, which makes it ready to be drawn
       
    81     ActivateL();   
       
    82 
       
    83     }
       
    84  
       
    85 // -----------------------------------------------------------------------------
       
    86 // CGSTPlayerAppView::CGSTPlayerAppView()
       
    87 // C++ default constructor can NOT contain any code, that might leave.
       
    88 // -----------------------------------------------------------------------------
       
    89 //
       
    90 CGSTPlayerAppView::CGSTPlayerAppView()
       
    91     {
       
    92     // No implementation required
       
    93   	gst_init(NULL,NULL);  
       
    94   	
       
    95     iCGlibEventHandler = CGlibEventHandler::NewL();
       
    96 	iCGlibEventHandler->Start();
       
    97     }
       
    98 
       
    99 
       
   100 // -----------------------------------------------------------------------------
       
   101 // CGSTPlayerAppView::~CGSTPlayerAppView()
       
   102 // Destructor.
       
   103 // -----------------------------------------------------------------------------
       
   104 //
       
   105 CGSTPlayerAppView::~CGSTPlayerAppView()
       
   106     {
       
   107     // No implementation required
       
   108     
       
   109     delete iRte;
       
   110     
       
   111     if(iCGlibEventHandler)
       
   112     {
       
   113     	iCGlibEventHandler->Stop();
       
   114         	delete iCGlibEventHandler;
       
   115     }
       
   116     }
       
   117 
       
   118 
       
   119 // -----------------------------------------------------------------------------
       
   120 // CGSTPlayerAppView::Draw()
       
   121 // Draws the display.
       
   122 // -----------------------------------------------------------------------------
       
   123 //
       
   124 void CGSTPlayerAppView::Draw( const TRect& /*aRect*/ ) const
       
   125     {
       
   126     // Get the standard graphics context
       
   127     CWindowGc& gc = SystemGc();
       
   128 
       
   129     // Gets the control's extent
       
   130     TRect drawRect( Rect());
       
   131 
       
   132     // Clears the screen
       
   133     gc.Clear( drawRect );
       
   134     
       
   135   	}
       
   136 void CGSTPlayerAppView::DrawText(const TDesC& aText, const TRgb aRgb)
       
   137     {
       
   138     TRAPD(err, iRte->AddTextL(aText, aRgb));
       
   139     if (err != KErrNone)
       
   140         {
       
   141         ; // don't care but makes compiler happy
       
   142         }
       
   143     }
       
   144 
       
   145 
       
   146 // -----------------------------------------------------------------------------
       
   147 // CGSTPlayerAppView::SizeChanged()
       
   148 // Called by framework when the view size is changed.
       
   149 // -----------------------------------------------------------------------------
       
   150 //
       
   151 void CGSTPlayerAppView::SizeChanged()
       
   152     {  
       
   153     iRte->SetExtent(TPoint(0,0), Window().Size());
       
   154    DrawNow();
       
   155     }
       
   156 // End of File
       
   157 
       
   158 // ----------------------------------------------------------------------------
       
   159 // CGSTPlayerAppView::CountComponentControls
       
   160 // Called by the framework in compound controls
       
   161 // ----------------------------------------------------------------------------
       
   162 TInt CGSTPlayerAppView::CountComponentControls() const
       
   163     {
       
   164     return 1; // return number of controls inside this container
       
   165     }
       
   166 
       
   167 
       
   168 // ----------------------------------------------------------------------------
       
   169 // CGSTPlayerAppView::ComponentControl
       
   170 // Called by the framework in compound controls
       
   171 // ----------------------------------------------------------------------------
       
   172 CCoeControl* CGSTPlayerAppView::ComponentControl(TInt aIndex) const
       
   173     {
       
   174     switch (aIndex)
       
   175         {
       
   176     case 0:
       
   177         return iRte;
       
   178     default:
       
   179         return NULL;
       
   180         }
       
   181     }
       
   182 
       
   183