vtuis/videotelui/src/CVtUiEndCallButtonPane.cpp
branchRCL_3
changeset 12 f84a661cfc1d
child 13 50bbdc59f9c4
equal deleted inserted replaced
8:07d1685f0cd4 12:f84a661cfc1d
       
     1 /*
       
     2 * Copyright (c) 2009 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:  The container pane of end button.
       
    15 *
       
    16 */
       
    17 
       
    18 #include    <aknenv.h>
       
    19 #include    <aknlayoutscalable_apps.cdl.h>
       
    20 #include    <AknsBasicBackgroundControlContext.h>
       
    21 #include    <AknsDrawUtils.h>
       
    22 #include    <AknsSkinInstance.h>
       
    23 #include    <videotelui.rsg>
       
    24 #include    <cvtlogger.h>
       
    25 
       
    26 #include    "CVtUiEndCallButton.h"
       
    27 #include    "CVtUiEndCallButtonPane.h"
       
    28 #include    "videotelui.hrh"
       
    29 #include    "CVtUiAppUi.h"
       
    30 
       
    31 // -----------------------------------------------------------------------------
       
    32 // CVtUiEndCallButtonPane::CVtUiEndCallButtonPane
       
    33 // -----------------------------------------------------------------------------
       
    34 //
       
    35 CVtUiEndCallButtonPane::CVtUiEndCallButtonPane()
       
    36     {
       
    37     // No implementation required
       
    38     }
       
    39 
       
    40 // -----------------------------------------------------------------------------
       
    41 // CVtUiEndCallButtonPane::NewL
       
    42 // -----------------------------------------------------------------------------
       
    43 //
       
    44 CVtUiEndCallButtonPane* CVtUiEndCallButtonPane::NewL( const TRect& aRect )
       
    45     {
       
    46     CVtUiEndCallButtonPane* self =
       
    47             new (ELeave) CVtUiEndCallButtonPane();
       
    48     CleanupStack::PushL(self);
       
    49     self->ConstructL( aRect );
       
    50     CleanupStack::Pop(); // self;
       
    51     return self;
       
    52     }
       
    53 
       
    54 // -----------------------------------------------------------------------------
       
    55 // CVtUiEndCallButtonPane::ConstructL
       
    56 // -----------------------------------------------------------------------------
       
    57 //
       
    58 void CVtUiEndCallButtonPane::ConstructL( const TRect& aRect )
       
    59     {
       
    60     __VTPRINTENTER( "CVtUiEndCallButtonPane.ConstructL" )
       
    61     // Create a window for this application view
       
    62     CreateWindowL();
       
    63     
       
    64     // Set the windows size
       
    65     SetRect( aRect );
       
    66 
       
    67     CreateButtonUsingResourceL();
       
    68     GetButtonLayoutData();
       
    69     
       
    70 
       
    71     iBgContext = CAknsBasicBackgroundControlContext::NewL(
       
    72             KAknsIIDQsnBgAreaMain, Rect(), ETrue );
       
    73     
       
    74     // Activate the window, which makes it ready to be drawn
       
    75     ActivateL();
       
    76     __VTPRINTEXIT( "CVtUiEndCallButtonPane.ConstructL" )
       
    77     }
       
    78 
       
    79 // -----------------------------------------------------------------------------
       
    80 // CVtUiEndCallButtonPane::CVtUiEndCallButtonPane
       
    81 // -----------------------------------------------------------------------------
       
    82 //
       
    83 CVtUiEndCallButtonPane::~CVtUiEndCallButtonPane()
       
    84     {
       
    85     __VTPRINTENTER( "CVtUiEndCallButtonPane.~" )
       
    86     if ( iEndButton )
       
    87         {
       
    88         delete iEndButton;
       
    89         }
       
    90     
       
    91     if ( iBgContext )
       
    92         {
       
    93         delete iBgContext;
       
    94         }
       
    95     __VTPRINTEXIT( "CVtUiEndCallButtonPane.~" )
       
    96     }
       
    97 
       
    98 // -----------------------------------------------------------------------------
       
    99 // CVtUiEndCallButtonPane::CountComponentControls
       
   100 // -----------------------------------------------------------------------------
       
   101 //
       
   102 TInt CVtUiEndCallButtonPane::CountComponentControls() const
       
   103     {
       
   104     return iEndButton ? 1 : 0;
       
   105     }
       
   106 
       
   107 // -----------------------------------------------------------------------------
       
   108 // CVtUiEndCallButtonPane::ComponentControl
       
   109 // -----------------------------------------------------------------------------
       
   110 //
       
   111 CCoeControl* CVtUiEndCallButtonPane::ComponentControl(TInt aIndex) const
       
   112     {
       
   113     return iEndButton;
       
   114     }
       
   115 
       
   116 // -----------------------------------------------------------------------------
       
   117 // CVtUiEndCallButtonPane::Draw
       
   118 // -----------------------------------------------------------------------------
       
   119 //
       
   120 void CVtUiEndCallButtonPane::Draw(const TRect& aRect) const
       
   121     {
       
   122     __VTPRINTENTER( "CVtUiEndCallButtonPane.Draw" )
       
   123     CWindowGc& gc = SystemGc();
       
   124     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   125     MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
       
   126     AknsDrawUtils::Background( skin, cc, this, gc, Rect() );
       
   127     __VTPRINTEXIT( "CVtUiEndCallButtonPane.Draw" )
       
   128     }
       
   129 
       
   130 // -----------------------------------------------------------------------------
       
   131 // CVtUiEndCallButtonPane::SizeChanged
       
   132 // -----------------------------------------------------------------------------
       
   133 //
       
   134 void CVtUiEndCallButtonPane::SizeChanged()
       
   135     {
       
   136     __VTPRINTENTER( "CVtUiEndCallButtonPane.SizeChanged" )
       
   137     if( iEndButton )
       
   138         {
       
   139         GetButtonLayoutData();
       
   140         }
       
   141     if( iBgContext )
       
   142         {
       
   143         TRect bgRect;
       
   144         AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, bgRect );
       
   145         iBgContext->SetRect( bgRect );
       
   146         }
       
   147     __VTPRINTEXIT( "CVtUiEndCallButtonPane.SizeChanged" )
       
   148     }
       
   149 
       
   150 // -----------------------------------------------------------------------------
       
   151 // CVtUiEndCallButtonPane::MopSupplyObject
       
   152 // -----------------------------------------------------------------------------
       
   153 //
       
   154 TTypeUid::Ptr CVtUiEndCallButtonPane::MopSupplyObject(TTypeUid aId)
       
   155     {
       
   156     __VTPRINTENTER( "CVtUiEndCallButtonPane.MopSupplyObject" )
       
   157     // Required during rendering of the background skin in Draw()
       
   158     if (aId.iUid == MAknsControlContext::ETypeId)
       
   159         {
       
   160          __VTPRINTEXIT( "CVtUiEndCallButtonPane.MopSupplyObject.1" )
       
   161         return MAknsControlContext::SupplyMopObject( aId, iBgContext );
       
   162         }
       
   163     __VTPRINTEXIT( "CVtUiEndCallButtonPane.MopSupplyObject.2" )
       
   164     return CCoeControl::MopSupplyObject( aId );
       
   165     }
       
   166 
       
   167 // -----------------------------------------------------------------------------
       
   168 // CVtUiEndCallButtonPane::HandleControlEventL
       
   169 // -----------------------------------------------------------------------------
       
   170 //
       
   171 void CVtUiEndCallButtonPane::HandleControlEventL( CCoeControl* aControl, 
       
   172                                                   TCoeEvent aEventType )
       
   173     {
       
   174     __VTPRINTENTER( "CVtUiEndCallButtonPane.HandleControlEventL" )
       
   175     if ( aEventType != EEventStateChanged )
       
   176         {
       
   177         __VTPRINTEXIT( "CVtUiEndCallButtonPane.HandleControlEventL" )
       
   178         return;
       
   179         }
       
   180     CVtUiAppUi* appUi = STATIC_CAST( CVtUiAppUi*, CCoeEnv::Static()->AppUi() );
       
   181     appUi->CmdSimulateKeyEvent( EStdKeyNo );
       
   182     __VTPRINTEXIT( "CVtUiEndCallButtonPane.HandleControlEventL" )
       
   183     }
       
   184 
       
   185 // -----------------------------------------------------------------------------
       
   186 // CVtUiEndCallButtonPane::CreateButtonUsingResourceL
       
   187 // -----------------------------------------------------------------------------
       
   188 //
       
   189 void CVtUiEndCallButtonPane::CreateButtonUsingResourceL()
       
   190     {
       
   191     __VTPRINTENTER( "CVtUiEndCallButtonPane.CreateButtonUsingResourceL" )
       
   192     iEndButton = CVtUiEndCallButton::NewL();
       
   193     iEndButton->ConstructFromResourceL( R_VIDEOTELUI_END_CALL_BUTTON );
       
   194     iEndButton->SetContainerWindowL( *this );
       
   195     iEndButton->SetRect( Rect() );
       
   196     iEndButton->SetObserver( this );
       
   197     iEndButton->MakeVisible( ETrue );
       
   198     iEndButton->ActivateL();
       
   199     __VTPRINTEXIT( "CVtUiEndCallButtonPane.CreateButtonUsingResourceL" )
       
   200     }
       
   201 
       
   202 // -----------------------------------------------------------------------------
       
   203 // CVtUiEndCallButtonPane::GetButtonLayoutData
       
   204 // -----------------------------------------------------------------------------
       
   205 //
       
   206 void CVtUiEndCallButtonPane::GetButtonLayoutData()
       
   207     {
       
   208     __VTPRINTENTER( "CVtUiEndCallButtonPane.GetButtonLayoutData" )
       
   209     AknLayoutUtils::LayoutControl( 
       
   210             iEndButton, 
       
   211             Rect(), 
       
   212             AknLayoutScalable_Apps::bg_button_pane_cp034( 0, 0, 0) );
       
   213 
       
   214     
       
   215     TAknLayoutText text;
       
   216     text.LayoutText( Rect(), 
       
   217             AknLayoutScalable_Apps::vidtel_button_pane_t1( 
       
   218                     0 ).LayoutLine());
       
   219 
       
   220     TAknLayoutRect icon;
       
   221     icon.LayoutRect( Rect(), 
       
   222             AknLayoutScalable_Apps::vidtel_button_pane_g1( 
       
   223                     0 ).LayoutLine());
       
   224     
       
   225     iEndButton->SetIconSize( icon.Rect().Size() );
       
   226 
       
   227     iEndButton->SetLayout( text, icon.Rect() );
       
   228      __VTPRINTEXIT( "CVtUiEndCallButtonPane.GetButtonLayoutData" )
       
   229     }