os/textandloc/fontservices/textshaperplugin/test/S60HindiDemo/src/MainViewcontainer.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/textandloc/fontservices/textshaperplugin/test/S60HindiDemo/src/MainViewcontainer.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,592 @@
     1.4 +/*
     1.5 +* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description: 
    1.18 +* Series 60 version of Hindi Demo application
    1.19 +* Implementation of CMainViewContainer
    1.20 +*
    1.21 +*/
    1.22 +
    1.23 +
    1.24 +#include <aknutils.h>
    1.25 +#include <eikgted.h>
    1.26 +#include <HindiDemo.rsg>
    1.27 +#include <uikon.hrh>
    1.28 +#include "MainViewcontainer.h"
    1.29 +
    1.30 +// for font dialog
    1.31 +#include <eikenv.h>
    1.32 +#include <aknnotewrappers.h>
    1.33 +
    1.34 +// hindi sample text 
    1.35 +// sample 1
    1.36 +_LIT16(KNile1,"\x0915\x094D\x0937\x0924\x094D\x0930\x093F\x092F\x0020\x0909\x0926\x094D\x0926\x0947\x0936\x094D\x0020\x0915\x094D\x0937\x093F\x092A\x094D\x0930");
    1.37 +_LIT16(KNile2,"\x092d\x0942\x0930\x094d\x092d\x0941\x0935\x0903\x0020\x0938\x094d\x0935\x0903\x0020\x0924\x0924\x094d\x0938\x0935\x093f\x0924\x0941\x0930\x094d\x0935\x0930\x0947\x0923\x094d\x092f\x0902");
    1.38 +_LIT16(KNile3,"\x092d\x0930\x094d\x0917\x094b\x0020\x0926\x0947\x0935\x0938\x094d\x092f\x0020\x0927\x0940\x092e\x0939\x093f\x0020\x0927\x093f\x092f\x094b\x0020\x092f\x094b\x0928\x0903\x0020\x092a\x094d\x0930\x091a\x094b\x0926\x092f\x093e\x0924\x094d");
    1.39 +
    1.40 +// sample 2
    1.41 +_LIT16(KNile4,"\x092f\x0924\x094d\x0930\x0020\x092f\x094b\x0917\x0947\x0936\x094d\x0935\x0930\x0020\x0915\x0943\x0937\x094d\x0923\x094b\x0020\x092f\x0924\x094d\x0930\x0020\x092a\x093e\x0930\x094d\x0925\x094b\x0020\x0927\x0930\x094d\x0928\x0941\x0927\x0930\x0903");
    1.42 +_LIT16(KNile5,"\x0924\x0924\x094d\x0930\x0020\x0936\x094d\x0930\x0940\x0930\x094d\x0935\x093f\x091c\x092f\x094b\x0020\x092d\x0942\x0924\x093f\x0930\x094d\x0927\x0941\x0935\x093e\x0020\x0928\x0940\x0924\x093f\x0930\x094d\x092e\x0924\x093f\x0930\x094d\x092e\x092e");
    1.43 +_LIT16(KNile6,"\x0915\x0941\x0924\x0938\x094d\x0924\x094d\x0935\x093e\x0020\x0915\x0936\x094d\x092e\x0932\x092e\x093f\x0926\x0902\x0020\x0935\x093f\x0936\x092e\x0947\x0020\x0938\x092e\x0941\x092a\x0938\x094d\x0925\x093f\x0924\x092e\x094d");
    1.44 +
    1.45 +// sample 3
    1.46 +_LIT16(KNile7,"\x0905\x0928\x093e\x0930\x094d\x092f\x091c\x0941\x0937\x094d\x091f\x092e\x0938\x094d\x0935\x0930\x094d\x0917\x094d\x092f\x092e\x0915\x0940\x0930\x094d\x0924\x093f\x0915\x0930\x092e\x0930\x094d\x091c\x0941\x0928");
    1.47 +_LIT16(KNile8,"\x0915\x094d\x0932\x0948\x092c\x094d\x092f\x0902\x0020\x092e\x0020\x0938\x094d\x092e\x0020\x0917\x092e\x0903\x0020\x092a\x093e\x0930\x094d\x0925\x0928\x0948\x0924\x0924\x094d\x0924\x094d\x0935\x092f\x094d\x092f\x0941\x092a\x092a\x0926\x094d\x092f\x0924\x0947");
    1.48 +_LIT16(KNile9,"\x0915\x094d\x0937\x0941\x0926\x094d\x0930\x0902\x0020\x0939\x0943\x0926\x092f\x0926\x094c\x0930\x094d\x092c\x0932\x094d\x092f\x0902\x0020\x0924\x094d\x092f\x0915\x094d\x0924\x094d\x0935\x094b\x0924\x094d\x0924\x093f\x0937\x094d\x091f\x0020\x092a\x0930\x0902\x0924\x092a");
    1.49 +
    1.50 +// test 4 -  assorted sample data
    1.51 +_LIT16(KTest1,"\x091c\x092e\x094d\x0918\x0940\x0902\x091a\x094d\x092f\x0940\x0020\x0920\x094d\x0920\x094d\x0920\x094d\x0920\x094d");
    1.52 +_LIT16(KTest2,"'\x091A\x092A\x0940' '\x0915\x092E\x0932' '\x092D\x0930\x0924'");
    1.53 +_LIT16(KTest3,"\x091A\x092A\x42 \x0915\x092A\x42 \x0915\x092A\x44 \x0930\x094D\x0930\x094D\x0930\x094D\x0930\x093e\x0903\x0020");
    1.54 +
    1.55 +CMainViewContainer* CMainViewContainer::NewL(const TRect& aRect)
    1.56 +	{
    1.57 +	CMainViewContainer* self = CMainViewContainer::NewLC(aRect);
    1.58 +	CleanupStack::Pop(self);
    1.59 +	return self;
    1.60 +	}
    1.61 +
    1.62 +CMainViewContainer* CMainViewContainer::NewLC(const TRect& aRect)
    1.63 +	{
    1.64 +  	CMainViewContainer* self = new (ELeave) CMainViewContainer;
    1.65 +  	CleanupStack::PushL(self);
    1.66 +  	self->ConstructL(aRect);
    1.67 +  	return self;
    1.68 +	}
    1.69 +
    1.70 +CMainViewContainer::CMainViewContainer()
    1.71 +	{
    1.72 +	}
    1.73 +
    1.74 +CMainViewContainer::~CMainViewContainer()
    1.75 +	{
    1.76 +  	CleanupComponents();
    1.77 +  	iCtrlArray.Reset();
    1.78 +	}
    1.79 +
    1.80 +// -----------------------------------------------------------------------
    1.81 +// Routine that creates and initializes designed components
    1.82 +//
    1.83 +// -----------------------------------------------------------------------
    1.84 +void CMainViewContainer::InitComponentsL()
    1.85 +	{
    1.86 +  	CEikStatusPane * sp = iEikonEnv->AppUiFactory()->StatusPane();
    1.87 +	  	{
    1.88 +	    iContextPane = ( CAknContextPane * ) sp->ControlL( TUid::Uid( EEikStatusPaneUidContext ) );
    1.89 +	    TResourceReader reader;
    1.90 +	    iCoeEnv->CreateResourceReaderLC( reader, R_MAINVIEW_IAKNCONTEXTPANE1 );
    1.91 +	    iContextPane->SetFromResourceL( reader );
    1.92 +	    CleanupStack::PopAndDestroy();
    1.93 +	  	}
    1.94 +	  	{
    1.95 +	    iTitlePane = ( CAknTitlePane * ) sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) );
    1.96 +	    TResourceReader reader;
    1.97 +	    iCoeEnv->CreateResourceReaderLC( reader, R_MAINVIEW_IAKNTITLEPANE1 );
    1.98 +	    iTitlePane->SetFromResourceL( reader );
    1.99 +	    CleanupStack::PopAndDestroy();
   1.100 +	  	}
   1.101 +  	iNaviPane = ( CAknNavigationControlContainer * ) sp->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) );
   1.102 +  	iEikonEnv->AppUiFactory()->StatusPane()->SwitchLayoutL( R_AVKON_STATUS_PANE_LAYOUT_USUAL );
   1.103 +  	iBackgroundColor = iEikonEnv->Color( EColorControlBackground );
   1.104 +	}
   1.105 +
   1.106 +// -----------------------------------------------------------------------
   1.107 +// Routine that cleans up designed components
   1.108 +//
   1.109 +// -----------------------------------------------------------------------
   1.110 +void CMainViewContainer::CleanupComponents()
   1.111 +	{
   1.112 +  	delete iNaviDecorator;
   1.113 +	}
   1.114 +
   1.115 +void CMainViewContainer::ConstructL(const TRect& aRect)
   1.116 +	{
   1.117 +	CreateWindowL();
   1.118 +	SetRect(aRect);
   1.119 +	InitComponentsL();
   1.120 +	ActivateL();
   1.121 +
   1.122 +  	ChangeSample(1);
   1.123 + 	SetFontSize(200);
   1.124 + 	ChangeFont();
   1.125 +	}
   1.126 +
   1.127 +void CMainViewContainer::Draw(const TRect& /* aRect */) const
   1.128 +	{
   1.129 +  	CWindowGc& gc = SystemGc();
   1.130 +	DrawHindiText( gc );
   1.131 +	}
   1.132 +
   1.133 +void CMainViewContainer::ChangeSample( TInt aSample)
   1.134 +	{
   1.135 +	iSample = aSample;
   1.136 +	if (iSample > 4) 
   1.137 +		iSample =1; 
   1.138 +	if (iSample < 1) 
   1.139 +		iSample =4; 
   1.140 +	}
   1.141 +
   1.142 +void CMainViewContainer::ChangeFont()
   1.143 +	{
   1.144 +	iSelectedFont++;
   1.145 +	int iNumTypefaces = iCoeEnv->ScreenDevice()->NumTypefaces();
   1.146 +	if (iSelectedFont >= iNumTypefaces || iSelectedFont < 0)
   1.147 +		iSelectedFont = 0;
   1.148 +	}
   1.149 +
   1.150 +void CMainViewContainer::ChangePreviousFont()
   1.151 +	{
   1.152 +	iSelectedFont--;
   1.153 +	int iNumTypefaces = iCoeEnv->ScreenDevice()->NumTypefaces();
   1.154 +	if (iSelectedFont >= iNumTypefaces || iSelectedFont < 0)
   1.155 +		iSelectedFont = iNumTypefaces-1;
   1.156 +	}
   1.157 +	
   1.158 +void CMainViewContainer::SetHindiFont( TFontSpec& aFontSpec )
   1.159 +	{
   1.160 +	iFontSpec = aFontSpec;
   1.161 +	}
   1.162 +
   1.163 +void CMainViewContainer::SetFontSize( TInt aFontSize )
   1.164 +	{
   1.165 +	iFontSize = aFontSize;
   1.166 +	}
   1.167 +
   1.168 +void CMainViewContainer::SetUnderLine( enum TFontUnderline aUnderLine )
   1.169 +	{
   1.170 +	iUnderLine = aUnderLine;
   1.171 +	}
   1.172 + 
   1.173 +enum TFontUnderline CMainViewContainer::GetUnderLine()
   1.174 +	{
   1.175 +	return 	iUnderLine;
   1.176 +	}
   1.177 +	
   1.178 +TInt CMainViewContainer::GetFontSize()
   1.179 +	{
   1.180 +	return iFontSize;
   1.181 +	}
   1.182 +
   1.183 +TInt CMainViewContainer::GetSample()
   1.184 +	{
   1.185 +	return iSample;
   1.186 +	}
   1.187 +	
   1.188 +void CMainViewContainer::DisplayAvailableFonts()
   1.189 +	{
   1.190 +	TBuf<500> listofFonts;
   1.191 +	
   1.192 +	TInt iNumTypefaces = iCoeEnv->ScreenDevice()->NumTypefaces();
   1.193 +	TTypefaceSupport myTypefaceSupport;
   1.194 +	for(TInt i = 0; i < iNumTypefaces-1; i++)
   1.195 +		{
   1.196 +		// get the details of the next available typeface
   1.197 +		iCoeEnv->ScreenDevice()->TypefaceSupport(myTypefaceSupport,i);
   1.198 +		listofFonts.Append( myTypefaceSupport.iTypeface.iName.Des());
   1.199 +		listofFonts.Append( _L("\n"));
   1.200 +		}
   1.201 +
   1.202 +    CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
   1.203 +    informationNote->ExecuteLD(listofFonts);			
   1.204 +	}
   1.205 +		
   1.206 +const TInt UnicodeZeroWidthNonJoiner = 0x200C;
   1.207 +
   1.208 +/* Display Hindi without shaping by inserting a Unicode Zero Width Non Joiner
   1.209 +character bewteen each character
   1.210 +aInput the Hindi text to be displayed
   1.211 +aOutput the same text with the ZWNJ characters added, This buffer must be big enough
   1.212 +*/
   1.213 +void CMainViewContainer::DisableShaping(const TDesC* aInput, TDes& aOutput ) const
   1.214 +	{
   1.215 +	aOutput.Zero();
   1.216 +	for (TInt i = 0; i < aInput->Length(); i++ )
   1.217 +		{
   1.218 +		aOutput.Append( aInput->Mid(i,1) );
   1.219 +		aOutput.Append( UnicodeZeroWidthNonJoiner );
   1.220 +		}
   1.221 +	}
   1.222 +	
   1.223 +void CMainViewContainer::DrawHindiText(CWindowGc& aGc) const
   1.224 +	{
   1.225 +
   1.226 +	// start with test font
   1.227 +	CFont* testFont;
   1.228 +	_LIT(KTestFontName,"DejaVu Sans Condensed");
   1.229 +	TFontSpec testFontSpec(KTestFontName,100); 
   1.230 +	CGraphicsDevice* screenDevice=iCoeEnv->ScreenDevice();
   1.231 +	screenDevice->GetNearestFontInTwips(testFont,testFontSpec);
   1.232 +
   1.233 +	// set the selected font
   1.234 +	CFont* IndicFont;
   1.235 +	TBuf<200> textFontName;
   1.236 +
   1.237 +	TTypefaceSupport myTypefaceSupport;
   1.238 +	screenDevice->TypefaceSupport(myTypefaceSupport,iSelectedFont);
   1.239 +		
   1.240 +	textFontName.Copy(myTypefaceSupport.iTypeface.iName.Des());
   1.241 +
   1.242 +	TFontSpec indicFontSpec(textFontName,iFontSize); 
   1.243 +	screenDevice->GetNearestFontInTwips(IndicFont,indicFontSpec);
   1.244 +
   1.245 +	// set the required attributes
   1.246 +	aGc.UseFont(testFont);
   1.247 +	aGc.SetPenColor(KRgbBlack);
   1.248 +	aGc.SetBrushColor(KRgbWhite);
   1.249 +	aGc.CancelClippingRect();
   1.250 +	aGc.SetBrushStyle(CGraphicsContext::ESolidBrush); 
   1.251 +
   1.252 +	// Set the text drawing position & draw
   1.253 +	TRect posRect(10,10, 600, 40);
   1.254 +	TBuf<100> textLine;
   1.255 +	TBuf<100> textLine2;
   1.256 +	TBuf<20> fontLine;
   1.257 +	textLine.Append(_L("Sample:"));
   1.258 +	
   1.259 +	switch( iSample )
   1.260 +		{
   1.261 +		case 1:
   1.262 +			textLine.Append(_L("1 "));
   1.263 +			break;
   1.264 +		case 2:
   1.265 +			textLine.Append(_L("2 "));
   1.266 +			break;
   1.267 +		case 3:
   1.268 +			textLine.Append(_L("3 "));
   1.269 +			break;
   1.270 +		case 4:
   1.271 +			textLine.Append(_L("test "));
   1.272 +			break;
   1.273 +		default:
   1.274 +			textLine.Append(_L("what? "));
   1.275 +			break;
   1.276 +	 	}
   1.277 +	fontLine.Format(_L("font %d:"), iSelectedFont );	
   1.278 +	textLine.Append(fontLine);
   1.279 +	textLine.Append(indicFontSpec.iTypeface.iName);
   1.280 +	aGc.DrawText(textLine,posRect, 14);
   1.281 +
   1.282 +	TRect pos2rect(10,30, 600, 60);
   1.283 +	textLine2.Format(_L("Size:%dpt black is not shaped, blue is"),iFontSize/20);
   1.284 +	aGc.DrawText(textLine2, pos2rect, 14);
   1.285 +	
   1.286 +	// Discard and destroy the test font
   1.287 +	aGc.DiscardFont();
   1.288 +	screenDevice->ReleaseFont(testFont);
   1.289 +	
   1.290 +	// set the required attributes
   1.291 +	aGc.UseFont(IndicFont);
   1.292 +	aGc.SetPenColor(KRgbBlack);
   1.293 +	aGc.SetBrushColor(KRgbWhite);
   1.294 +	aGc.SetBrushStyle(CGraphicsContext::ESolidBrush); 
   1.295 +	aGc.CancelClippingRect();
   1.296 +	aGc.SetUnderlineStyle(iUnderLine);
   1.297 +
   1.298 +	// some rectangles to fit the text in
   1.299 +	const TInt baseLineOffset  = 32;
   1.300 +	const TInt gap = 40;
   1.301 +	const TInt start = 50;
   1.302 +	TRect textRect( 10,start,          800, start+(gap) );
   1.303 +	TRect textRect2(10,start+(gap),    800, start+(gap*2));
   1.304 +	TRect textRect3(10,start+(gap*2),  800, start+(gap*3));
   1.305 +	TRect textRect4(10,start+(gap*3),  800, start+(gap*4));
   1.306 +	TRect textRect5(10,start+(gap*4),  800, start+(gap*5));
   1.307 +	TRect textRect6(10,start+(gap*5),  800, start+(gap*6));
   1.308 +
   1.309 +	TBuf<200> textWithoutShaping;
   1.310 +
   1.311 +	// Draw some Hindi in a rectangle
   1.312 +	switch (iSample)
   1.313 +	{
   1.314 +	default:
   1.315 +	case 1:
   1.316 +	
   1.317 +		// First draw in Black with shaping disabled
   1.318 +		DisableShaping(&KNile1, textWithoutShaping );
   1.319 +		aGc.SetPenColor(KRgbBlack);
   1.320 +		aGc.DrawText(textWithoutShaping, textRect, baseLineOffset, CGraphicsContext::ELeft);
   1.321 +
   1.322 +		// Now in Blue with shaping
   1.323 +		aGc.SetPenColor(KRgbBlue);
   1.324 +		aGc.DrawText(KNile1, textRect2, baseLineOffset, CGraphicsContext::ELeft);
   1.325 +	
   1.326 +		//--------------------------------------------------------------------------
   1.327 +		// Without the Layout Engine
   1.328 +		aGc.SetPenColor(KRgbBlack);
   1.329 +		DisableShaping(&KNile2, textWithoutShaping );
   1.330 +		aGc.DrawText(textWithoutShaping, textRect3, baseLineOffset, CGraphicsContext::ELeft);
   1.331 +
   1.332 +		aGc.SetPenColor(KRgbBlue);
   1.333 +		aGc.DrawText(KNile2, textRect4, baseLineOffset, CGraphicsContext::ELeft);
   1.334 +		//--------------------------------------------------------------------------
   1.335 +		// Without the Layout Engine
   1.336 +		DisableShaping(&KNile3, textWithoutShaping );
   1.337 +		aGc.SetPenColor(KRgbBlack);
   1.338 +		aGc.DrawText(textWithoutShaping, textRect5, baseLineOffset, CGraphicsContext::ELeft);
   1.339 +
   1.340 +		aGc.SetPenColor(KRgbBlue);
   1.341 +		aGc.DrawText(KNile3, textRect6, baseLineOffset, CGraphicsContext::ELeft);
   1.342 +		//--------------------------------------------------------------------------
   1.343 +		break;
   1.344 +		
   1.345 +	case 2:		
   1.346 +		DisableShaping(&KNile4, textWithoutShaping );
   1.347 +		aGc.SetPenColor(KRgbBlack);
   1.348 +		aGc.DrawText(textWithoutShaping, textRect, baseLineOffset, CGraphicsContext::ELeft);
   1.349 +
   1.350 +		aGc.SetPenColor(KRgbBlue);
   1.351 +		aGc.DrawText(KNile4, textRect2, baseLineOffset, CGraphicsContext::ELeft);
   1.352 +	
   1.353 +		//--------------------------------------------------------------------------
   1.354 +		// Without the Layout Engine
   1.355 +		DisableShaping(&KNile5, textWithoutShaping );
   1.356 +		aGc.SetPenColor(KRgbBlack);
   1.357 +		aGc.DrawText(textWithoutShaping, textRect3, baseLineOffset, CGraphicsContext::ELeft);
   1.358 +
   1.359 +		aGc.SetPenColor(KRgbBlue);
   1.360 +		aGc.DrawText(KNile5, textRect4, baseLineOffset, CGraphicsContext::ELeft);
   1.361 +		//--------------------------------------------------------------------------
   1.362 +		// Without the Layout Engine
   1.363 +		DisableShaping(&KNile6, textWithoutShaping );
   1.364 +		aGc.SetPenColor(KRgbBlack);
   1.365 +		aGc.DrawText(textWithoutShaping, textRect5, baseLineOffset, CGraphicsContext::ELeft);
   1.366 +
   1.367 +		aGc.SetPenColor(KRgbBlue);
   1.368 +		aGc.DrawText(KNile6, textRect6, baseLineOffset, CGraphicsContext::ELeft);
   1.369 +		//--------------------------------------------------------------------------
   1.370 +		break;
   1.371 +	
   1.372 +	case 3:	
   1.373 +		DisableShaping(&KNile7, textWithoutShaping );
   1.374 +		aGc.SetPenColor(KRgbBlack);
   1.375 +		aGc.DrawText(textWithoutShaping, textRect, baseLineOffset, CGraphicsContext::ELeft);
   1.376 +
   1.377 +		aGc.SetPenColor(KRgbBlue);
   1.378 +		aGc.DrawText(KNile7, textRect2, baseLineOffset, CGraphicsContext::ELeft);
   1.379 +	
   1.380 +		//--------------------------------------------------------------------------
   1.381 +		// Without the Layout Engine
   1.382 +		DisableShaping(&KNile8, textWithoutShaping );
   1.383 +		aGc.SetPenColor(KRgbBlack);
   1.384 +		aGc.DrawText(textWithoutShaping, textRect3, baseLineOffset, CGraphicsContext::ELeft);
   1.385 +
   1.386 +		aGc.SetPenColor(KRgbBlue);
   1.387 +		aGc.DrawText(KNile8, textRect4, baseLineOffset, CGraphicsContext::ELeft);
   1.388 +		//--------------------------------------------------------------------------
   1.389 +		// Without the Layout Engine
   1.390 +		DisableShaping(&KNile9, textWithoutShaping );
   1.391 +		aGc.SetPenColor(KRgbBlack);
   1.392 +		aGc.DrawText(textWithoutShaping, textRect5, baseLineOffset, CGraphicsContext::ELeft);
   1.393 +
   1.394 +		aGc.SetPenColor(KRgbBlue);
   1.395 +		aGc.DrawText(KNile9, textRect6, 100, CGraphicsContext::ELeft);
   1.396 +		//--------------------------------------------------------------------------
   1.397 +		break;
   1.398 +		
   1.399 +	case 4:
   1.400 +		// test 
   1.401 +		DisableShaping(&KTest1, textWithoutShaping );
   1.402 +		aGc.DrawText(textWithoutShaping, textRect, baseLineOffset, CGraphicsContext::ELeft);
   1.403 +
   1.404 +		aGc.SetPenColor(KRgbBlue);
   1.405 +		aGc.DrawText(KTest1, textRect2, baseLineOffset, CGraphicsContext::ELeft);
   1.406 +	
   1.407 +		//--------------------------------------------------------------------------
   1.408 +		// Without the Layout Engine
   1.409 +
   1.410 +		aGc.SetPenColor(KRgbBlack);
   1.411 +		DisableShaping(&KTest2, textWithoutShaping );
   1.412 +		aGc.DrawText(textWithoutShaping, textRect3, baseLineOffset, CGraphicsContext::ELeft);
   1.413 +		// With the Layout Engine
   1.414 +
   1.415 +		aGc.SetPenColor(KRgbBlue);
   1.416 +		aGc.DrawText(KTest2, textRect4, baseLineOffset, CGraphicsContext::ELeft);
   1.417 +		//--------------------------------------------------------------------------
   1.418 +		// Without the Layout Engine
   1.419 +
   1.420 +		aGc.SetPenColor(KRgbBlack);
   1.421 +		DisableShaping(&KTest3, textWithoutShaping );
   1.422 +		aGc.DrawText(textWithoutShaping, textRect5, baseLineOffset, CGraphicsContext::ELeft);
   1.423 +		// With the Layout Engine
   1.424 +
   1.425 +		aGc.SetPenColor(KRgbBlue);
   1.426 +		aGc.DrawText(KTest3, textRect6, baseLineOffset, CGraphicsContext::ELeft);
   1.427 +		//--------------------------------------------------------------------------
   1.428 +		
   1.429 +		break;
   1.430 +	}
   1.431 +		
   1.432 +	// Discard and destroy the font
   1.433 +	aGc.DiscardFont();
   1.434 +	screenDevice->ReleaseFont(IndicFont);
   1.435 +
   1.436 +	}
   1.437 +
   1.438 +
   1.439 +// -----------------------------------------------------------------------
   1.440 +// Returns the number of controls in the control group.
   1.441 +// -----------------------------------------------------------------------
   1.442 +TInt CMainViewContainer::CountComponentControls() const
   1.443 +	{
   1.444 +  	return iCtrlArray.Count();
   1.445 +	}
   1.446 +
   1.447 +// -----------------------------------------------------------------------
   1.448 +// Returns the component control identified by the given index
   1.449 +// -----------------------------------------------------------------------
   1.450 +CCoeControl* CMainViewContainer::ComponentControl(TInt aIndex) const
   1.451 +	{
   1.452 +  	return (CCoeControl*)iCtrlArray[aIndex];
   1.453 +	}
   1.454 +
   1.455 +// -----------------------------------------------------------------------
   1.456 +// Method invoked by control framework to handle key events
   1.457 +// -----------------------------------------------------------------------
   1.458 +TKeyResponse CMainViewContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
   1.459 +	{
   1.460 +  	if (HandleKeyEvents(aKeyEvent, aType))
   1.461 +    	return EKeyWasConsumed;
   1.462 +  	else if(iFocusedControl)
   1.463 +    	return iFocusedControl->OfferKeyEventL(aKeyEvent, aType);
   1.464 +  	else
   1.465 +    	return EKeyWasNotConsumed;
   1.466 +	}
   1.467 +
   1.468 +// -----------------------------------------------------------------------
   1.469 +// Method invoked to handle an event from an observed control
   1.470 +// -----------------------------------------------------------------------
   1.471 +void CMainViewContainer::HandleControlEventL(CCoeControl * aControl, TCoeEvent aEventType)
   1.472 +	{
   1.473 +  	DispatchControlEvents(aControl, aEventType);
   1.474 +	}
   1.475 +
   1.476 +// -----------------------------------------------------------------------
   1.477 +// This method attemps to dispatch commands to individual handlers
   1.478 +//
   1.479 +// -----------------------------------------------------------------------
   1.480 +bool CMainViewContainer::DispatchViewCommandEvents(TInt aCommand)
   1.481 +	{
   1.482 +	//InfoMessage
   1.483 +    _LIT(message,"Copyright (c) 2006 Symbian Software Ltd.\n All rights reserved.");
   1.484 +  	switch (aCommand) 
   1.485 +  		{
   1.486 +		/* sample 1*/
   1.487 +		case 1009:
   1.488 +			ChangeSample(1);
   1.489 +			break;
   1.490 +		/* sample 2*/
   1.491 +		case 1010:
   1.492 +			ChangeSample(2);
   1.493 +			break;
   1.494 +		/* sample 3*/
   1.495 +		case 1011:
   1.496 +			ChangeSample(3);
   1.497 +			break;
   1.498 +		/* sample 4*/
   1.499 +		case 1012:
   1.500 +			ChangeSample(4);
   1.501 +			break;
   1.502 +		/* Font */
   1.503 +		case 1017:
   1.504 +			ChangeFont();
   1.505 +			break;
   1.506 +		case 1018:
   1.507 +			ChangePreviousFont();
   1.508 +			break;
   1.509 +		case 1020:
   1.510 +			DisplayAvailableFonts();
   1.511 +			break;	
   1.512 +		case 1014:
   1.513 +			// reduce font size
   1.514 + 			SetFontSize(GetFontSize() -20);
   1.515 + 			break;
   1.516 +		case 1016:
   1.517 +			// increase font size
   1.518 + 			SetFontSize(GetFontSize() +20);
   1.519 + 			break;
   1.520 +		case 1015:
   1.521 +    		CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
   1.522 +            informationNote->ExecuteLD(message);			
   1.523 +            break;
   1.524 +    	default:
   1.525 +    		// this command has not been processed by this view so..
   1.526 +			return false;
   1.527 +  		}
   1.528 +	DrawDeferred();
   1.529 +	return true;
   1.530 +	}
   1.531 +
   1.532 +// -----------------------------------------------------------------------
   1.533 +// Routine that attempts to dispatch Control Events
   1.534 +//
   1.535 +// -----------------------------------------------------------------------
   1.536 +void CMainViewContainer::DispatchControlEvents(CCoeControl * /* aControl */, TCoeEvent /* aEventType */)
   1.537 +	{
   1.538 +	}
   1.539 +
   1.540 +// -----------------------------------------------------------------------
   1.541 +// Routine where you can handle key events
   1.542 +// -----------------------------------------------------------------------
   1.543 +bool CMainViewContainer::HandleKeyEvents(const TKeyEvent& aKeyEvent, TEventCode /* aType */)
   1.544 +	{
   1.545 +  	switch (aKeyEvent.iCode) 
   1.546 +  		{
   1.547 +  	  	case EKeyUpArrow:
   1.548 + 			// increase font size
   1.549 + 			SetFontSize(GetFontSize() +20);
   1.550 + 			break;
   1.551 +  	  	case EKeyDownArrow:
   1.552 + 			// increase font size
   1.553 + 			SetFontSize(GetFontSize() -20);
   1.554 + 			break;
   1.555 +  	  	case EKeyLeftArrow:
   1.556 + 			// next sample
   1.557 +			ChangeSample(GetSample()-1);
   1.558 + 			break;
   1.559 +  	  	case EKeyRightArrow:
   1.560 + 			// last sample
   1.561 +			ChangeSample(GetSample()+1);
   1.562 + 			break;
   1.563 +  	  	case '8':
   1.564 +  			if (GetUnderLine() == EUnderlineOff)
   1.565 +  				SetUnderLine ( EUnderlineOn );
   1.566 +			else
   1.567 +  				SetUnderLine ( EUnderlineOff );
   1.568 +			break;
   1.569 +		case '3':
   1.570 +			ChangeFont();
   1.571 +			break;
   1.572 +		case '1':
   1.573 +			ChangePreviousFont();
   1.574 +			break;
   1.575 + 	  	default:
   1.576 +	   		return false;
   1.577 + 	  	}
   1.578 + 	  	
   1.579 +	DrawDeferred();
   1.580 + 	return true;  	
   1.581 +	}
   1.582 +
   1.583 +// -----------------------------------------------------------------------
   1.584 +// Helper routine to manage Control Focus
   1.585 +// -----------------------------------------------------------------------
   1.586 +void CMainViewContainer::ChangeFocus(CCoeControl * aNewControl)
   1.587 +	{
   1.588 +  	if(iFocusedControl)
   1.589 +    	iFocusedControl->SetFocus(EFalse);
   1.590 +  	iFocusedControl = aNewControl;
   1.591 +  	if(iFocusedControl)
   1.592 +    	iFocusedControl->SetFocus(ETrue);
   1.593 +	}
   1.594 +
   1.595 +