lafagnosticuifoundation/cone/tef/tmultiptrtestchildcontrol.cpp
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include <gdi.h>
       
    17 #include <coecntrl.h>
       
    18 
       
    19 #include "tmultiptrtestchildcontrol.h"
       
    20 
       
    21 
       
    22 
       
    23 CMultiPtrTestChildControl::CMultiPtrTestChildControl()
       
    24 : iDoAppUiCallback( ETrue )
       
    25 	{
       
    26 	}
       
    27 
       
    28 
       
    29 CMultiPtrTestChildControl::~CMultiPtrTestChildControl()
       
    30 	{
       
    31  	iCoeEnv->ReleaseScreenFont(iFont);
       
    32  	delete iName;
       
    33 	}
       
    34 	
       
    35 
       
    36 void CMultiPtrTestChildControl::ConstructL( const TDesC& aName )
       
    37 	{
       
    38 	CMultiPtrTestControlBase::ConstructL();
       
    39 	iAppUi = static_cast<CConeMultiPtrCompoundTestAppUi*>(ControlEnv()->AppUi());
       
    40 	
       
    41 	TFontSpec spec(_L("Arial"),240);
       
    42 	iFont = iCoeEnv->CreateScreenFontL( spec );
       
    43 	
       
    44 	iName = aName.AllocL();
       
    45 	EnableDragEvents();
       
    46 	}
       
    47 
       
    48 
       
    49 void CMultiPtrTestChildControl::WriteName( CWindowGc& aGc, const TDesC& aText ) const 
       
    50 	{
       
    51 	TRect rect = Rect();
       
    52 	rect.Shrink( 3, 3 );
       
    53 	aGc.UseFont( iFont );
       
    54 	TInt ascent = ( rect.iBr.iY - rect.iTl.iY-iFont->HeightInPixels() ) / 2 + iFont->AscentInPixels();
       
    55 	aGc.SetPenColor( KRgbBlack );
       
    56 	aGc.SetBrushStyle( CGraphicsContext::ESolidBrush );
       
    57 	aGc.DrawText( aText, rect, ascent, CGraphicsContext::ELeft );	
       
    58 	aGc.DiscardFont();
       
    59 	}
       
    60 
       
    61 
       
    62 void CMultiPtrTestChildControl::Draw( const TRect& ) const
       
    63 	{
       
    64 	CWindowGc& gc = SystemGc();
       
    65 	
       
    66 	TRect rect = Rect();
       
    67 	gc.SetBrushColor( KRgbYellow );
       
    68 	gc.DrawRect( rect );
       
    69 	
       
    70 	rect.Shrink( 1, 1 );
       
    71 	gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
       
    72 	gc.DrawRect( rect );
       
    73 	
       
    74 	WriteName( gc, *iName );
       
    75 	}	
       
    76 
       
    77 
       
    78 const TDesC& CMultiPtrTestChildControl::WhoAmI() const
       
    79 	{
       
    80 	return *iName;
       
    81 	}
       
    82 
       
    83 
       
    84 void CMultiPtrTestChildControl::HandlePointerEventL( const TPointerEvent& aPointerEvent )
       
    85 	{
       
    86 	TBuf<256> buf( iName->Des() );	
       
    87 	RDebug::Print( _L("%S"), &buf );
       
    88 	
       
    89 	CMultiPtrTestControlBase::HandlePointerEventL( aPointerEvent );
       
    90 	}
       
    91 
       
    92 
       
    93 /**
       
    94  PV in CMultiPtrTestControlBase
       
    95 */
       
    96 void CMultiPtrTestChildControl::NotifyControlL( TInt aNotify )
       
    97 	{
       
    98 	if( !iDoAppUiCallback )
       
    99 		{
       
   100 		return;
       
   101 		}
       
   102 	
       
   103 	switch( aNotify )
       
   104 		{
       
   105 	case EMultiPtrTestFailed:
       
   106 			iAppUi->Failed();
       
   107 			break;
       
   108 		
       
   109 	case EmultiPtrNext:	
       
   110 			iAppUi->NextSetOfEventsL();
       
   111 		break;
       
   112 		
       
   113 	default:
       
   114 		User::Leave( KErrArgument );
       
   115 		break;
       
   116 		}
       
   117 
       
   118 	}
       
   119 
       
   120 void CMultiPtrTestChildControl::SetAppUiCallback( TBool aCallback )
       
   121 	{
       
   122 	iDoAppUiCallback = aCallback;
       
   123 	}