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