os/textandloc/fontservices/textshaperplugin/test/S60HindiDemo/src/MainViewcontainer.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 /*
     2 * Copyright (c) 2006-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: 
    15 * Series 60 version of Hindi Demo application
    16 * Implementation of CMainViewContainer
    17 *
    18 */
    19 
    20 
    21 #include <aknutils.h>
    22 #include <eikgted.h>
    23 #include <HindiDemo.rsg>
    24 #include <uikon.hrh>
    25 #include "MainViewcontainer.h"
    26 
    27 // for font dialog
    28 #include <eikenv.h>
    29 #include <aknnotewrappers.h>
    30 
    31 // hindi sample text 
    32 // sample 1
    33 _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");
    34 _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");
    35 _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");
    36 
    37 // sample 2
    38 _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");
    39 _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");
    40 _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");
    41 
    42 // sample 3
    43 _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");
    44 _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");
    45 _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");
    46 
    47 // test 4 -  assorted sample data
    48 _LIT16(KTest1,"\x091c\x092e\x094d\x0918\x0940\x0902\x091a\x094d\x092f\x0940\x0020\x0920\x094d\x0920\x094d\x0920\x094d\x0920\x094d");
    49 _LIT16(KTest2,"'\x091A\x092A\x0940' '\x0915\x092E\x0932' '\x092D\x0930\x0924'");
    50 _LIT16(KTest3,"\x091A\x092A\x42 \x0915\x092A\x42 \x0915\x092A\x44 \x0930\x094D\x0930\x094D\x0930\x094D\x0930\x093e\x0903\x0020");
    51 
    52 CMainViewContainer* CMainViewContainer::NewL(const TRect& aRect)
    53 	{
    54 	CMainViewContainer* self = CMainViewContainer::NewLC(aRect);
    55 	CleanupStack::Pop(self);
    56 	return self;
    57 	}
    58 
    59 CMainViewContainer* CMainViewContainer::NewLC(const TRect& aRect)
    60 	{
    61   	CMainViewContainer* self = new (ELeave) CMainViewContainer;
    62   	CleanupStack::PushL(self);
    63   	self->ConstructL(aRect);
    64   	return self;
    65 	}
    66 
    67 CMainViewContainer::CMainViewContainer()
    68 	{
    69 	}
    70 
    71 CMainViewContainer::~CMainViewContainer()
    72 	{
    73   	CleanupComponents();
    74   	iCtrlArray.Reset();
    75 	}
    76 
    77 // -----------------------------------------------------------------------
    78 // Routine that creates and initializes designed components
    79 //
    80 // -----------------------------------------------------------------------
    81 void CMainViewContainer::InitComponentsL()
    82 	{
    83   	CEikStatusPane * sp = iEikonEnv->AppUiFactory()->StatusPane();
    84 	  	{
    85 	    iContextPane = ( CAknContextPane * ) sp->ControlL( TUid::Uid( EEikStatusPaneUidContext ) );
    86 	    TResourceReader reader;
    87 	    iCoeEnv->CreateResourceReaderLC( reader, R_MAINVIEW_IAKNCONTEXTPANE1 );
    88 	    iContextPane->SetFromResourceL( reader );
    89 	    CleanupStack::PopAndDestroy();
    90 	  	}
    91 	  	{
    92 	    iTitlePane = ( CAknTitlePane * ) sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) );
    93 	    TResourceReader reader;
    94 	    iCoeEnv->CreateResourceReaderLC( reader, R_MAINVIEW_IAKNTITLEPANE1 );
    95 	    iTitlePane->SetFromResourceL( reader );
    96 	    CleanupStack::PopAndDestroy();
    97 	  	}
    98   	iNaviPane = ( CAknNavigationControlContainer * ) sp->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) );
    99   	iEikonEnv->AppUiFactory()->StatusPane()->SwitchLayoutL( R_AVKON_STATUS_PANE_LAYOUT_USUAL );
   100   	iBackgroundColor = iEikonEnv->Color( EColorControlBackground );
   101 	}
   102 
   103 // -----------------------------------------------------------------------
   104 // Routine that cleans up designed components
   105 //
   106 // -----------------------------------------------------------------------
   107 void CMainViewContainer::CleanupComponents()
   108 	{
   109   	delete iNaviDecorator;
   110 	}
   111 
   112 void CMainViewContainer::ConstructL(const TRect& aRect)
   113 	{
   114 	CreateWindowL();
   115 	SetRect(aRect);
   116 	InitComponentsL();
   117 	ActivateL();
   118 
   119   	ChangeSample(1);
   120  	SetFontSize(200);
   121  	ChangeFont();
   122 	}
   123 
   124 void CMainViewContainer::Draw(const TRect& /* aRect */) const
   125 	{
   126   	CWindowGc& gc = SystemGc();
   127 	DrawHindiText( gc );
   128 	}
   129 
   130 void CMainViewContainer::ChangeSample( TInt aSample)
   131 	{
   132 	iSample = aSample;
   133 	if (iSample > 4) 
   134 		iSample =1; 
   135 	if (iSample < 1) 
   136 		iSample =4; 
   137 	}
   138 
   139 void CMainViewContainer::ChangeFont()
   140 	{
   141 	iSelectedFont++;
   142 	int iNumTypefaces = iCoeEnv->ScreenDevice()->NumTypefaces();
   143 	if (iSelectedFont >= iNumTypefaces || iSelectedFont < 0)
   144 		iSelectedFont = 0;
   145 	}
   146 
   147 void CMainViewContainer::ChangePreviousFont()
   148 	{
   149 	iSelectedFont--;
   150 	int iNumTypefaces = iCoeEnv->ScreenDevice()->NumTypefaces();
   151 	if (iSelectedFont >= iNumTypefaces || iSelectedFont < 0)
   152 		iSelectedFont = iNumTypefaces-1;
   153 	}
   154 	
   155 void CMainViewContainer::SetHindiFont( TFontSpec& aFontSpec )
   156 	{
   157 	iFontSpec = aFontSpec;
   158 	}
   159 
   160 void CMainViewContainer::SetFontSize( TInt aFontSize )
   161 	{
   162 	iFontSize = aFontSize;
   163 	}
   164 
   165 void CMainViewContainer::SetUnderLine( enum TFontUnderline aUnderLine )
   166 	{
   167 	iUnderLine = aUnderLine;
   168 	}
   169  
   170 enum TFontUnderline CMainViewContainer::GetUnderLine()
   171 	{
   172 	return 	iUnderLine;
   173 	}
   174 	
   175 TInt CMainViewContainer::GetFontSize()
   176 	{
   177 	return iFontSize;
   178 	}
   179 
   180 TInt CMainViewContainer::GetSample()
   181 	{
   182 	return iSample;
   183 	}
   184 	
   185 void CMainViewContainer::DisplayAvailableFonts()
   186 	{
   187 	TBuf<500> listofFonts;
   188 	
   189 	TInt iNumTypefaces = iCoeEnv->ScreenDevice()->NumTypefaces();
   190 	TTypefaceSupport myTypefaceSupport;
   191 	for(TInt i = 0; i < iNumTypefaces-1; i++)
   192 		{
   193 		// get the details of the next available typeface
   194 		iCoeEnv->ScreenDevice()->TypefaceSupport(myTypefaceSupport,i);
   195 		listofFonts.Append( myTypefaceSupport.iTypeface.iName.Des());
   196 		listofFonts.Append( _L("\n"));
   197 		}
   198 
   199     CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
   200     informationNote->ExecuteLD(listofFonts);			
   201 	}
   202 		
   203 const TInt UnicodeZeroWidthNonJoiner = 0x200C;
   204 
   205 /* Display Hindi without shaping by inserting a Unicode Zero Width Non Joiner
   206 character bewteen each character
   207 aInput the Hindi text to be displayed
   208 aOutput the same text with the ZWNJ characters added, This buffer must be big enough
   209 */
   210 void CMainViewContainer::DisableShaping(const TDesC* aInput, TDes& aOutput ) const
   211 	{
   212 	aOutput.Zero();
   213 	for (TInt i = 0; i < aInput->Length(); i++ )
   214 		{
   215 		aOutput.Append( aInput->Mid(i,1) );
   216 		aOutput.Append( UnicodeZeroWidthNonJoiner );
   217 		}
   218 	}
   219 	
   220 void CMainViewContainer::DrawHindiText(CWindowGc& aGc) const
   221 	{
   222 
   223 	// start with test font
   224 	CFont* testFont;
   225 	_LIT(KTestFontName,"DejaVu Sans Condensed");
   226 	TFontSpec testFontSpec(KTestFontName,100); 
   227 	CGraphicsDevice* screenDevice=iCoeEnv->ScreenDevice();
   228 	screenDevice->GetNearestFontInTwips(testFont,testFontSpec);
   229 
   230 	// set the selected font
   231 	CFont* IndicFont;
   232 	TBuf<200> textFontName;
   233 
   234 	TTypefaceSupport myTypefaceSupport;
   235 	screenDevice->TypefaceSupport(myTypefaceSupport,iSelectedFont);
   236 		
   237 	textFontName.Copy(myTypefaceSupport.iTypeface.iName.Des());
   238 
   239 	TFontSpec indicFontSpec(textFontName,iFontSize); 
   240 	screenDevice->GetNearestFontInTwips(IndicFont,indicFontSpec);
   241 
   242 	// set the required attributes
   243 	aGc.UseFont(testFont);
   244 	aGc.SetPenColor(KRgbBlack);
   245 	aGc.SetBrushColor(KRgbWhite);
   246 	aGc.CancelClippingRect();
   247 	aGc.SetBrushStyle(CGraphicsContext::ESolidBrush); 
   248 
   249 	// Set the text drawing position & draw
   250 	TRect posRect(10,10, 600, 40);
   251 	TBuf<100> textLine;
   252 	TBuf<100> textLine2;
   253 	TBuf<20> fontLine;
   254 	textLine.Append(_L("Sample:"));
   255 	
   256 	switch( iSample )
   257 		{
   258 		case 1:
   259 			textLine.Append(_L("1 "));
   260 			break;
   261 		case 2:
   262 			textLine.Append(_L("2 "));
   263 			break;
   264 		case 3:
   265 			textLine.Append(_L("3 "));
   266 			break;
   267 		case 4:
   268 			textLine.Append(_L("test "));
   269 			break;
   270 		default:
   271 			textLine.Append(_L("what? "));
   272 			break;
   273 	 	}
   274 	fontLine.Format(_L("font %d:"), iSelectedFont );	
   275 	textLine.Append(fontLine);
   276 	textLine.Append(indicFontSpec.iTypeface.iName);
   277 	aGc.DrawText(textLine,posRect, 14);
   278 
   279 	TRect pos2rect(10,30, 600, 60);
   280 	textLine2.Format(_L("Size:%dpt black is not shaped, blue is"),iFontSize/20);
   281 	aGc.DrawText(textLine2, pos2rect, 14);
   282 	
   283 	// Discard and destroy the test font
   284 	aGc.DiscardFont();
   285 	screenDevice->ReleaseFont(testFont);
   286 	
   287 	// set the required attributes
   288 	aGc.UseFont(IndicFont);
   289 	aGc.SetPenColor(KRgbBlack);
   290 	aGc.SetBrushColor(KRgbWhite);
   291 	aGc.SetBrushStyle(CGraphicsContext::ESolidBrush); 
   292 	aGc.CancelClippingRect();
   293 	aGc.SetUnderlineStyle(iUnderLine);
   294 
   295 	// some rectangles to fit the text in
   296 	const TInt baseLineOffset  = 32;
   297 	const TInt gap = 40;
   298 	const TInt start = 50;
   299 	TRect textRect( 10,start,          800, start+(gap) );
   300 	TRect textRect2(10,start+(gap),    800, start+(gap*2));
   301 	TRect textRect3(10,start+(gap*2),  800, start+(gap*3));
   302 	TRect textRect4(10,start+(gap*3),  800, start+(gap*4));
   303 	TRect textRect5(10,start+(gap*4),  800, start+(gap*5));
   304 	TRect textRect6(10,start+(gap*5),  800, start+(gap*6));
   305 
   306 	TBuf<200> textWithoutShaping;
   307 
   308 	// Draw some Hindi in a rectangle
   309 	switch (iSample)
   310 	{
   311 	default:
   312 	case 1:
   313 	
   314 		// First draw in Black with shaping disabled
   315 		DisableShaping(&KNile1, textWithoutShaping );
   316 		aGc.SetPenColor(KRgbBlack);
   317 		aGc.DrawText(textWithoutShaping, textRect, baseLineOffset, CGraphicsContext::ELeft);
   318 
   319 		// Now in Blue with shaping
   320 		aGc.SetPenColor(KRgbBlue);
   321 		aGc.DrawText(KNile1, textRect2, baseLineOffset, CGraphicsContext::ELeft);
   322 	
   323 		//--------------------------------------------------------------------------
   324 		// Without the Layout Engine
   325 		aGc.SetPenColor(KRgbBlack);
   326 		DisableShaping(&KNile2, textWithoutShaping );
   327 		aGc.DrawText(textWithoutShaping, textRect3, baseLineOffset, CGraphicsContext::ELeft);
   328 
   329 		aGc.SetPenColor(KRgbBlue);
   330 		aGc.DrawText(KNile2, textRect4, baseLineOffset, CGraphicsContext::ELeft);
   331 		//--------------------------------------------------------------------------
   332 		// Without the Layout Engine
   333 		DisableShaping(&KNile3, textWithoutShaping );
   334 		aGc.SetPenColor(KRgbBlack);
   335 		aGc.DrawText(textWithoutShaping, textRect5, baseLineOffset, CGraphicsContext::ELeft);
   336 
   337 		aGc.SetPenColor(KRgbBlue);
   338 		aGc.DrawText(KNile3, textRect6, baseLineOffset, CGraphicsContext::ELeft);
   339 		//--------------------------------------------------------------------------
   340 		break;
   341 		
   342 	case 2:		
   343 		DisableShaping(&KNile4, textWithoutShaping );
   344 		aGc.SetPenColor(KRgbBlack);
   345 		aGc.DrawText(textWithoutShaping, textRect, baseLineOffset, CGraphicsContext::ELeft);
   346 
   347 		aGc.SetPenColor(KRgbBlue);
   348 		aGc.DrawText(KNile4, textRect2, baseLineOffset, CGraphicsContext::ELeft);
   349 	
   350 		//--------------------------------------------------------------------------
   351 		// Without the Layout Engine
   352 		DisableShaping(&KNile5, textWithoutShaping );
   353 		aGc.SetPenColor(KRgbBlack);
   354 		aGc.DrawText(textWithoutShaping, textRect3, baseLineOffset, CGraphicsContext::ELeft);
   355 
   356 		aGc.SetPenColor(KRgbBlue);
   357 		aGc.DrawText(KNile5, textRect4, baseLineOffset, CGraphicsContext::ELeft);
   358 		//--------------------------------------------------------------------------
   359 		// Without the Layout Engine
   360 		DisableShaping(&KNile6, textWithoutShaping );
   361 		aGc.SetPenColor(KRgbBlack);
   362 		aGc.DrawText(textWithoutShaping, textRect5, baseLineOffset, CGraphicsContext::ELeft);
   363 
   364 		aGc.SetPenColor(KRgbBlue);
   365 		aGc.DrawText(KNile6, textRect6, baseLineOffset, CGraphicsContext::ELeft);
   366 		//--------------------------------------------------------------------------
   367 		break;
   368 	
   369 	case 3:	
   370 		DisableShaping(&KNile7, textWithoutShaping );
   371 		aGc.SetPenColor(KRgbBlack);
   372 		aGc.DrawText(textWithoutShaping, textRect, baseLineOffset, CGraphicsContext::ELeft);
   373 
   374 		aGc.SetPenColor(KRgbBlue);
   375 		aGc.DrawText(KNile7, textRect2, baseLineOffset, CGraphicsContext::ELeft);
   376 	
   377 		//--------------------------------------------------------------------------
   378 		// Without the Layout Engine
   379 		DisableShaping(&KNile8, textWithoutShaping );
   380 		aGc.SetPenColor(KRgbBlack);
   381 		aGc.DrawText(textWithoutShaping, textRect3, baseLineOffset, CGraphicsContext::ELeft);
   382 
   383 		aGc.SetPenColor(KRgbBlue);
   384 		aGc.DrawText(KNile8, textRect4, baseLineOffset, CGraphicsContext::ELeft);
   385 		//--------------------------------------------------------------------------
   386 		// Without the Layout Engine
   387 		DisableShaping(&KNile9, textWithoutShaping );
   388 		aGc.SetPenColor(KRgbBlack);
   389 		aGc.DrawText(textWithoutShaping, textRect5, baseLineOffset, CGraphicsContext::ELeft);
   390 
   391 		aGc.SetPenColor(KRgbBlue);
   392 		aGc.DrawText(KNile9, textRect6, 100, CGraphicsContext::ELeft);
   393 		//--------------------------------------------------------------------------
   394 		break;
   395 		
   396 	case 4:
   397 		// test 
   398 		DisableShaping(&KTest1, textWithoutShaping );
   399 		aGc.DrawText(textWithoutShaping, textRect, baseLineOffset, CGraphicsContext::ELeft);
   400 
   401 		aGc.SetPenColor(KRgbBlue);
   402 		aGc.DrawText(KTest1, textRect2, baseLineOffset, CGraphicsContext::ELeft);
   403 	
   404 		//--------------------------------------------------------------------------
   405 		// Without the Layout Engine
   406 
   407 		aGc.SetPenColor(KRgbBlack);
   408 		DisableShaping(&KTest2, textWithoutShaping );
   409 		aGc.DrawText(textWithoutShaping, textRect3, baseLineOffset, CGraphicsContext::ELeft);
   410 		// With the Layout Engine
   411 
   412 		aGc.SetPenColor(KRgbBlue);
   413 		aGc.DrawText(KTest2, textRect4, baseLineOffset, CGraphicsContext::ELeft);
   414 		//--------------------------------------------------------------------------
   415 		// Without the Layout Engine
   416 
   417 		aGc.SetPenColor(KRgbBlack);
   418 		DisableShaping(&KTest3, textWithoutShaping );
   419 		aGc.DrawText(textWithoutShaping, textRect5, baseLineOffset, CGraphicsContext::ELeft);
   420 		// With the Layout Engine
   421 
   422 		aGc.SetPenColor(KRgbBlue);
   423 		aGc.DrawText(KTest3, textRect6, baseLineOffset, CGraphicsContext::ELeft);
   424 		//--------------------------------------------------------------------------
   425 		
   426 		break;
   427 	}
   428 		
   429 	// Discard and destroy the font
   430 	aGc.DiscardFont();
   431 	screenDevice->ReleaseFont(IndicFont);
   432 
   433 	}
   434 
   435 
   436 // -----------------------------------------------------------------------
   437 // Returns the number of controls in the control group.
   438 // -----------------------------------------------------------------------
   439 TInt CMainViewContainer::CountComponentControls() const
   440 	{
   441   	return iCtrlArray.Count();
   442 	}
   443 
   444 // -----------------------------------------------------------------------
   445 // Returns the component control identified by the given index
   446 // -----------------------------------------------------------------------
   447 CCoeControl* CMainViewContainer::ComponentControl(TInt aIndex) const
   448 	{
   449   	return (CCoeControl*)iCtrlArray[aIndex];
   450 	}
   451 
   452 // -----------------------------------------------------------------------
   453 // Method invoked by control framework to handle key events
   454 // -----------------------------------------------------------------------
   455 TKeyResponse CMainViewContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
   456 	{
   457   	if (HandleKeyEvents(aKeyEvent, aType))
   458     	return EKeyWasConsumed;
   459   	else if(iFocusedControl)
   460     	return iFocusedControl->OfferKeyEventL(aKeyEvent, aType);
   461   	else
   462     	return EKeyWasNotConsumed;
   463 	}
   464 
   465 // -----------------------------------------------------------------------
   466 // Method invoked to handle an event from an observed control
   467 // -----------------------------------------------------------------------
   468 void CMainViewContainer::HandleControlEventL(CCoeControl * aControl, TCoeEvent aEventType)
   469 	{
   470   	DispatchControlEvents(aControl, aEventType);
   471 	}
   472 
   473 // -----------------------------------------------------------------------
   474 // This method attemps to dispatch commands to individual handlers
   475 //
   476 // -----------------------------------------------------------------------
   477 bool CMainViewContainer::DispatchViewCommandEvents(TInt aCommand)
   478 	{
   479 	//InfoMessage
   480     _LIT(message,"Copyright (c) 2006 Symbian Software Ltd.\n All rights reserved.");
   481   	switch (aCommand) 
   482   		{
   483 		/* sample 1*/
   484 		case 1009:
   485 			ChangeSample(1);
   486 			break;
   487 		/* sample 2*/
   488 		case 1010:
   489 			ChangeSample(2);
   490 			break;
   491 		/* sample 3*/
   492 		case 1011:
   493 			ChangeSample(3);
   494 			break;
   495 		/* sample 4*/
   496 		case 1012:
   497 			ChangeSample(4);
   498 			break;
   499 		/* Font */
   500 		case 1017:
   501 			ChangeFont();
   502 			break;
   503 		case 1018:
   504 			ChangePreviousFont();
   505 			break;
   506 		case 1020:
   507 			DisplayAvailableFonts();
   508 			break;	
   509 		case 1014:
   510 			// reduce font size
   511  			SetFontSize(GetFontSize() -20);
   512  			break;
   513 		case 1016:
   514 			// increase font size
   515  			SetFontSize(GetFontSize() +20);
   516  			break;
   517 		case 1015:
   518     		CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
   519             informationNote->ExecuteLD(message);			
   520             break;
   521     	default:
   522     		// this command has not been processed by this view so..
   523 			return false;
   524   		}
   525 	DrawDeferred();
   526 	return true;
   527 	}
   528 
   529 // -----------------------------------------------------------------------
   530 // Routine that attempts to dispatch Control Events
   531 //
   532 // -----------------------------------------------------------------------
   533 void CMainViewContainer::DispatchControlEvents(CCoeControl * /* aControl */, TCoeEvent /* aEventType */)
   534 	{
   535 	}
   536 
   537 // -----------------------------------------------------------------------
   538 // Routine where you can handle key events
   539 // -----------------------------------------------------------------------
   540 bool CMainViewContainer::HandleKeyEvents(const TKeyEvent& aKeyEvent, TEventCode /* aType */)
   541 	{
   542   	switch (aKeyEvent.iCode) 
   543   		{
   544   	  	case EKeyUpArrow:
   545  			// increase font size
   546  			SetFontSize(GetFontSize() +20);
   547  			break;
   548   	  	case EKeyDownArrow:
   549  			// increase font size
   550  			SetFontSize(GetFontSize() -20);
   551  			break;
   552   	  	case EKeyLeftArrow:
   553  			// next sample
   554 			ChangeSample(GetSample()-1);
   555  			break;
   556   	  	case EKeyRightArrow:
   557  			// last sample
   558 			ChangeSample(GetSample()+1);
   559  			break;
   560   	  	case '8':
   561   			if (GetUnderLine() == EUnderlineOff)
   562   				SetUnderLine ( EUnderlineOn );
   563 			else
   564   				SetUnderLine ( EUnderlineOff );
   565 			break;
   566 		case '3':
   567 			ChangeFont();
   568 			break;
   569 		case '1':
   570 			ChangePreviousFont();
   571 			break;
   572  	  	default:
   573 	   		return false;
   574  	  	}
   575  	  	
   576 	DrawDeferred();
   577  	return true;  	
   578 	}
   579 
   580 // -----------------------------------------------------------------------
   581 // Helper routine to manage Control Focus
   582 // -----------------------------------------------------------------------
   583 void CMainViewContainer::ChangeFocus(CCoeControl * aNewControl)
   584 	{
   585   	if(iFocusedControl)
   586     	iFocusedControl->SetFocus(EFalse);
   587   	iFocusedControl = aNewControl;
   588   	if(iFocusedControl)
   589     	iFocusedControl->SetFocus(ETrue);
   590 	}
   591 
   592