mmappfw_plat/asx_parser_api/tsrc/AsxParserTest/src/EdwinTestControl.cpp
changeset 0 a2952bb97e68
equal deleted inserted replaced
-1:000000000000 0:a2952bb97e68
       
     1 /*
       
     2 * Copyright (c) 2002 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:  EdwinTestControl.cpp
       
    15 *
       
    16 */
       
    17 
       
    18 // Version : %version: 3.1.1 %
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 #include "EdwinTestControl.h"
       
    24 #include <eikenv.h>
       
    25 #include <aknsutils.h> 
       
    26 #include <aknsdrawutils.h> 
       
    27 #include <aknutils.h> 
       
    28 #include <aknsbasicbackgroundcontrolcontext.h>
       
    29 
       
    30 
       
    31 CEdwinTestControl::~CEdwinTestControl()
       
    32 	{
       
    33 	delete iEditWin;
       
    34 	iEditWin = NULL;
       
    35 	delete iBgContext;
       
    36 	iBgContext = NULL;
       
    37 	}   
       
    38  
       
    39 CEdwinTestControl* CEdwinTestControl::NewL(void)
       
    40     {
       
    41     CEdwinTestControl* self = new(ELeave)CEdwinTestControl();
       
    42     CleanupStack::PushL( self );
       
    43     self->ConstructL();
       
    44     CleanupStack::Pop( self );
       
    45     return self;
       
    46     }
       
    47  
       
    48 void CEdwinTestControl::ConstructL()
       
    49     {
       
    50     CreateWindowL();
       
    51  
       
    52     iEditWin = new (ELeave) CEikEdwin();
       
    53     iEditWin->ConstructL( 0, 100, 100, 1 );
       
    54     iEditWin->SetContainerWindowL( *this );
       
    55     iEditWin->CreateTextViewL();
       
    56 //    iEditWin->SetInputCapabilitiesL( TCoeInputCapabilities::EAllText );
       
    57     
       
    58 	// make first with no size at all
       
    59 	iBgContext = CAknsBasicBackgroundControlContext::NewL(KAknsIIDQsnBgScreen,TRect(0,0,1,1), ETrue );
       
    60 	// Setting rect will cause SizeChanged to be called
       
    61 	// and iBgContext size & position is updated accordingly.
       
    62 	SetRect( CEikonEnv::Static()->EikAppUi()->ClientRect() );	
       
    63 	
       
    64 	ActivateL();
       
    65 	DrawNow();
       
    66     }
       
    67  
       
    68 void CEdwinTestControl::SizeChanged()
       
    69 	{
       
    70 	if ( iBgContext )
       
    71 		{
       
    72 		iBgContext->SetRect(Rect());
       
    73  
       
    74 		if ( &Window() )
       
    75 			{
       
    76 			iBgContext->SetParentPos( PositionRelativeToScreen() );
       
    77 			}
       
    78 		}
       
    79 	if ( iEditWin )
       
    80 		{
       
    81 		iEditWin->SetRect(Rect());	
       
    82 		}
       
    83 	}
       
    84  
       
    85  
       
    86 void CEdwinTestControl::HandleResourceChange( TInt aType )
       
    87 	{
       
    88 	TRect rect;
       
    89  
       
    90     if ( aType == KEikDynamicLayoutVariantSwitch )
       
    91     	{    
       
    92         AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, rect);
       
    93         SetRect(rect);
       
    94     	}
       
    95  
       
    96 	CCoeControl::HandleResourceChange(aType);
       
    97 	}
       
    98  
       
    99  
       
   100 TTypeUid::Ptr CEdwinTestControl::MopSupplyObject(TTypeUid aId)
       
   101 	{
       
   102 	if ( iBgContext )
       
   103 		{
       
   104 		return MAknsControlContext::SupplyMopObject( aId, iBgContext );
       
   105 		}	
       
   106 
       
   107 	return CCoeControl::MopSupplyObject( aId );
       
   108 	}
       
   109  
       
   110  
       
   111 void CEdwinTestControl::Draw(const TRect& aRect) const
       
   112 	{
       
   113 	CWindowGc& gc = SystemGc();
       
   114     
       
   115     // draw background skin first.
       
   116   	MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   117 	AknsDrawUtils::Background( skin, iBgContext, this, gc, aRect );
       
   118 	}
       
   119 
       
   120 TInt CEdwinTestControl::CountComponentControls() const
       
   121 {
       
   122     return 1;
       
   123 }
       
   124  
       
   125 CCoeControl* CEdwinTestControl::ComponentControl(TInt aIndex) const
       
   126 {
       
   127     switch (aIndex)
       
   128     	{
       
   129         case 0:
       
   130         	return iEditWin;
       
   131         default:
       
   132             return 0;
       
   133     	}
       
   134 }
       
   135 
       
   136 void CEdwinTestControl::HandleControlEventL( CCoeControl* /*aControl*/, TCoeEvent /*aEventType*/)
       
   137 	{
       
   138     // TODO: Add your control event handler code here
       
   139 	}
       
   140 
       
   141 TKeyResponse CEdwinTestControl::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType )
       
   142 	{
       
   143 	if ( iEditWin )
       
   144 		{
       
   145 		return iEditWin->OfferKeyEventL( aKeyEvent, aType );
       
   146 		}
       
   147 	else
       
   148 		{
       
   149 		return EKeyWasNotConsumed;
       
   150 		}
       
   151 	}