sl@0: /* sl@0: * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * Series 60 version of Hindi Demo application sl@0: * Implementation of CMainViewContainer sl@0: * sl@0: */ sl@0: sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include "MainViewcontainer.h" sl@0: sl@0: // for font dialog sl@0: #include sl@0: #include sl@0: sl@0: // hindi sample text sl@0: // sample 1 sl@0: _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: _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: _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: sl@0: // sample 2 sl@0: _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: _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: _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: sl@0: // sample 3 sl@0: _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: _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: _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: sl@0: // test 4 - assorted sample data sl@0: _LIT16(KTest1,"\x091c\x092e\x094d\x0918\x0940\x0902\x091a\x094d\x092f\x0940\x0020\x0920\x094d\x0920\x094d\x0920\x094d\x0920\x094d"); sl@0: _LIT16(KTest2,"'\x091A\x092A\x0940' '\x0915\x092E\x0932' '\x092D\x0930\x0924'"); sl@0: _LIT16(KTest3,"\x091A\x092A\x42 \x0915\x092A\x42 \x0915\x092A\x44 \x0930\x094D\x0930\x094D\x0930\x094D\x0930\x093e\x0903\x0020"); sl@0: sl@0: CMainViewContainer* CMainViewContainer::NewL(const TRect& aRect) sl@0: { sl@0: CMainViewContainer* self = CMainViewContainer::NewLC(aRect); sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: CMainViewContainer* CMainViewContainer::NewLC(const TRect& aRect) sl@0: { sl@0: CMainViewContainer* self = new (ELeave) CMainViewContainer; sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(aRect); sl@0: return self; sl@0: } sl@0: sl@0: CMainViewContainer::CMainViewContainer() sl@0: { sl@0: } sl@0: sl@0: CMainViewContainer::~CMainViewContainer() sl@0: { sl@0: CleanupComponents(); sl@0: iCtrlArray.Reset(); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------- sl@0: // Routine that creates and initializes designed components sl@0: // sl@0: // ----------------------------------------------------------------------- sl@0: void CMainViewContainer::InitComponentsL() sl@0: { sl@0: CEikStatusPane * sp = iEikonEnv->AppUiFactory()->StatusPane(); sl@0: { sl@0: iContextPane = ( CAknContextPane * ) sp->ControlL( TUid::Uid( EEikStatusPaneUidContext ) ); sl@0: TResourceReader reader; sl@0: iCoeEnv->CreateResourceReaderLC( reader, R_MAINVIEW_IAKNCONTEXTPANE1 ); sl@0: iContextPane->SetFromResourceL( reader ); sl@0: CleanupStack::PopAndDestroy(); sl@0: } sl@0: { sl@0: iTitlePane = ( CAknTitlePane * ) sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ); sl@0: TResourceReader reader; sl@0: iCoeEnv->CreateResourceReaderLC( reader, R_MAINVIEW_IAKNTITLEPANE1 ); sl@0: iTitlePane->SetFromResourceL( reader ); sl@0: CleanupStack::PopAndDestroy(); sl@0: } sl@0: iNaviPane = ( CAknNavigationControlContainer * ) sp->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ); sl@0: iEikonEnv->AppUiFactory()->StatusPane()->SwitchLayoutL( R_AVKON_STATUS_PANE_LAYOUT_USUAL ); sl@0: iBackgroundColor = iEikonEnv->Color( EColorControlBackground ); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------- sl@0: // Routine that cleans up designed components sl@0: // sl@0: // ----------------------------------------------------------------------- sl@0: void CMainViewContainer::CleanupComponents() sl@0: { sl@0: delete iNaviDecorator; sl@0: } sl@0: sl@0: void CMainViewContainer::ConstructL(const TRect& aRect) sl@0: { sl@0: CreateWindowL(); sl@0: SetRect(aRect); sl@0: InitComponentsL(); sl@0: ActivateL(); sl@0: sl@0: ChangeSample(1); sl@0: SetFontSize(200); sl@0: ChangeFont(); sl@0: } sl@0: sl@0: void CMainViewContainer::Draw(const TRect& /* aRect */) const sl@0: { sl@0: CWindowGc& gc = SystemGc(); sl@0: DrawHindiText( gc ); sl@0: } sl@0: sl@0: void CMainViewContainer::ChangeSample( TInt aSample) sl@0: { sl@0: iSample = aSample; sl@0: if (iSample > 4) sl@0: iSample =1; sl@0: if (iSample < 1) sl@0: iSample =4; sl@0: } sl@0: sl@0: void CMainViewContainer::ChangeFont() sl@0: { sl@0: iSelectedFont++; sl@0: int iNumTypefaces = iCoeEnv->ScreenDevice()->NumTypefaces(); sl@0: if (iSelectedFont >= iNumTypefaces || iSelectedFont < 0) sl@0: iSelectedFont = 0; sl@0: } sl@0: sl@0: void CMainViewContainer::ChangePreviousFont() sl@0: { sl@0: iSelectedFont--; sl@0: int iNumTypefaces = iCoeEnv->ScreenDevice()->NumTypefaces(); sl@0: if (iSelectedFont >= iNumTypefaces || iSelectedFont < 0) sl@0: iSelectedFont = iNumTypefaces-1; sl@0: } sl@0: sl@0: void CMainViewContainer::SetHindiFont( TFontSpec& aFontSpec ) sl@0: { sl@0: iFontSpec = aFontSpec; sl@0: } sl@0: sl@0: void CMainViewContainer::SetFontSize( TInt aFontSize ) sl@0: { sl@0: iFontSize = aFontSize; sl@0: } sl@0: sl@0: void CMainViewContainer::SetUnderLine( enum TFontUnderline aUnderLine ) sl@0: { sl@0: iUnderLine = aUnderLine; sl@0: } sl@0: sl@0: enum TFontUnderline CMainViewContainer::GetUnderLine() sl@0: { sl@0: return iUnderLine; sl@0: } sl@0: sl@0: TInt CMainViewContainer::GetFontSize() sl@0: { sl@0: return iFontSize; sl@0: } sl@0: sl@0: TInt CMainViewContainer::GetSample() sl@0: { sl@0: return iSample; sl@0: } sl@0: sl@0: void CMainViewContainer::DisplayAvailableFonts() sl@0: { sl@0: TBuf<500> listofFonts; sl@0: sl@0: TInt iNumTypefaces = iCoeEnv->ScreenDevice()->NumTypefaces(); sl@0: TTypefaceSupport myTypefaceSupport; sl@0: for(TInt i = 0; i < iNumTypefaces-1; i++) sl@0: { sl@0: // get the details of the next available typeface sl@0: iCoeEnv->ScreenDevice()->TypefaceSupport(myTypefaceSupport,i); sl@0: listofFonts.Append( myTypefaceSupport.iTypeface.iName.Des()); sl@0: listofFonts.Append( _L("\n")); sl@0: } sl@0: sl@0: CAknInformationNote* informationNote = new (ELeave) CAknInformationNote; sl@0: informationNote->ExecuteLD(listofFonts); sl@0: } sl@0: sl@0: const TInt UnicodeZeroWidthNonJoiner = 0x200C; sl@0: sl@0: /* Display Hindi without shaping by inserting a Unicode Zero Width Non Joiner sl@0: character bewteen each character sl@0: aInput the Hindi text to be displayed sl@0: aOutput the same text with the ZWNJ characters added, This buffer must be big enough sl@0: */ sl@0: void CMainViewContainer::DisableShaping(const TDesC* aInput, TDes& aOutput ) const sl@0: { sl@0: aOutput.Zero(); sl@0: for (TInt i = 0; i < aInput->Length(); i++ ) sl@0: { sl@0: aOutput.Append( aInput->Mid(i,1) ); sl@0: aOutput.Append( UnicodeZeroWidthNonJoiner ); sl@0: } sl@0: } sl@0: sl@0: void CMainViewContainer::DrawHindiText(CWindowGc& aGc) const sl@0: { sl@0: sl@0: // start with test font sl@0: CFont* testFont; sl@0: _LIT(KTestFontName,"DejaVu Sans Condensed"); sl@0: TFontSpec testFontSpec(KTestFontName,100); sl@0: CGraphicsDevice* screenDevice=iCoeEnv->ScreenDevice(); sl@0: screenDevice->GetNearestFontInTwips(testFont,testFontSpec); sl@0: sl@0: // set the selected font sl@0: CFont* IndicFont; sl@0: TBuf<200> textFontName; sl@0: sl@0: TTypefaceSupport myTypefaceSupport; sl@0: screenDevice->TypefaceSupport(myTypefaceSupport,iSelectedFont); sl@0: sl@0: textFontName.Copy(myTypefaceSupport.iTypeface.iName.Des()); sl@0: sl@0: TFontSpec indicFontSpec(textFontName,iFontSize); sl@0: screenDevice->GetNearestFontInTwips(IndicFont,indicFontSpec); sl@0: sl@0: // set the required attributes sl@0: aGc.UseFont(testFont); sl@0: aGc.SetPenColor(KRgbBlack); sl@0: aGc.SetBrushColor(KRgbWhite); sl@0: aGc.CancelClippingRect(); sl@0: aGc.SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: sl@0: // Set the text drawing position & draw sl@0: TRect posRect(10,10, 600, 40); sl@0: TBuf<100> textLine; sl@0: TBuf<100> textLine2; sl@0: TBuf<20> fontLine; sl@0: textLine.Append(_L("Sample:")); sl@0: sl@0: switch( iSample ) sl@0: { sl@0: case 1: sl@0: textLine.Append(_L("1 ")); sl@0: break; sl@0: case 2: sl@0: textLine.Append(_L("2 ")); sl@0: break; sl@0: case 3: sl@0: textLine.Append(_L("3 ")); sl@0: break; sl@0: case 4: sl@0: textLine.Append(_L("test ")); sl@0: break; sl@0: default: sl@0: textLine.Append(_L("what? ")); sl@0: break; sl@0: } sl@0: fontLine.Format(_L("font %d:"), iSelectedFont ); sl@0: textLine.Append(fontLine); sl@0: textLine.Append(indicFontSpec.iTypeface.iName); sl@0: aGc.DrawText(textLine,posRect, 14); sl@0: sl@0: TRect pos2rect(10,30, 600, 60); sl@0: textLine2.Format(_L("Size:%dpt black is not shaped, blue is"),iFontSize/20); sl@0: aGc.DrawText(textLine2, pos2rect, 14); sl@0: sl@0: // Discard and destroy the test font sl@0: aGc.DiscardFont(); sl@0: screenDevice->ReleaseFont(testFont); sl@0: sl@0: // set the required attributes sl@0: aGc.UseFont(IndicFont); sl@0: aGc.SetPenColor(KRgbBlack); sl@0: aGc.SetBrushColor(KRgbWhite); sl@0: aGc.SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: aGc.CancelClippingRect(); sl@0: aGc.SetUnderlineStyle(iUnderLine); sl@0: sl@0: // some rectangles to fit the text in sl@0: const TInt baseLineOffset = 32; sl@0: const TInt gap = 40; sl@0: const TInt start = 50; sl@0: TRect textRect( 10,start, 800, start+(gap) ); sl@0: TRect textRect2(10,start+(gap), 800, start+(gap*2)); sl@0: TRect textRect3(10,start+(gap*2), 800, start+(gap*3)); sl@0: TRect textRect4(10,start+(gap*3), 800, start+(gap*4)); sl@0: TRect textRect5(10,start+(gap*4), 800, start+(gap*5)); sl@0: TRect textRect6(10,start+(gap*5), 800, start+(gap*6)); sl@0: sl@0: TBuf<200> textWithoutShaping; sl@0: sl@0: // Draw some Hindi in a rectangle sl@0: switch (iSample) sl@0: { sl@0: default: sl@0: case 1: sl@0: sl@0: // First draw in Black with shaping disabled sl@0: DisableShaping(&KNile1, textWithoutShaping ); sl@0: aGc.SetPenColor(KRgbBlack); sl@0: aGc.DrawText(textWithoutShaping, textRect, baseLineOffset, CGraphicsContext::ELeft); sl@0: sl@0: // Now in Blue with shaping sl@0: aGc.SetPenColor(KRgbBlue); sl@0: aGc.DrawText(KNile1, textRect2, baseLineOffset, CGraphicsContext::ELeft); sl@0: sl@0: //-------------------------------------------------------------------------- sl@0: // Without the Layout Engine sl@0: aGc.SetPenColor(KRgbBlack); sl@0: DisableShaping(&KNile2, textWithoutShaping ); sl@0: aGc.DrawText(textWithoutShaping, textRect3, baseLineOffset, CGraphicsContext::ELeft); sl@0: sl@0: aGc.SetPenColor(KRgbBlue); sl@0: aGc.DrawText(KNile2, textRect4, baseLineOffset, CGraphicsContext::ELeft); sl@0: //-------------------------------------------------------------------------- sl@0: // Without the Layout Engine sl@0: DisableShaping(&KNile3, textWithoutShaping ); sl@0: aGc.SetPenColor(KRgbBlack); sl@0: aGc.DrawText(textWithoutShaping, textRect5, baseLineOffset, CGraphicsContext::ELeft); sl@0: sl@0: aGc.SetPenColor(KRgbBlue); sl@0: aGc.DrawText(KNile3, textRect6, baseLineOffset, CGraphicsContext::ELeft); sl@0: //-------------------------------------------------------------------------- sl@0: break; sl@0: sl@0: case 2: sl@0: DisableShaping(&KNile4, textWithoutShaping ); sl@0: aGc.SetPenColor(KRgbBlack); sl@0: aGc.DrawText(textWithoutShaping, textRect, baseLineOffset, CGraphicsContext::ELeft); sl@0: sl@0: aGc.SetPenColor(KRgbBlue); sl@0: aGc.DrawText(KNile4, textRect2, baseLineOffset, CGraphicsContext::ELeft); sl@0: sl@0: //-------------------------------------------------------------------------- sl@0: // Without the Layout Engine sl@0: DisableShaping(&KNile5, textWithoutShaping ); sl@0: aGc.SetPenColor(KRgbBlack); sl@0: aGc.DrawText(textWithoutShaping, textRect3, baseLineOffset, CGraphicsContext::ELeft); sl@0: sl@0: aGc.SetPenColor(KRgbBlue); sl@0: aGc.DrawText(KNile5, textRect4, baseLineOffset, CGraphicsContext::ELeft); sl@0: //-------------------------------------------------------------------------- sl@0: // Without the Layout Engine sl@0: DisableShaping(&KNile6, textWithoutShaping ); sl@0: aGc.SetPenColor(KRgbBlack); sl@0: aGc.DrawText(textWithoutShaping, textRect5, baseLineOffset, CGraphicsContext::ELeft); sl@0: sl@0: aGc.SetPenColor(KRgbBlue); sl@0: aGc.DrawText(KNile6, textRect6, baseLineOffset, CGraphicsContext::ELeft); sl@0: //-------------------------------------------------------------------------- sl@0: break; sl@0: sl@0: case 3: sl@0: DisableShaping(&KNile7, textWithoutShaping ); sl@0: aGc.SetPenColor(KRgbBlack); sl@0: aGc.DrawText(textWithoutShaping, textRect, baseLineOffset, CGraphicsContext::ELeft); sl@0: sl@0: aGc.SetPenColor(KRgbBlue); sl@0: aGc.DrawText(KNile7, textRect2, baseLineOffset, CGraphicsContext::ELeft); sl@0: sl@0: //-------------------------------------------------------------------------- sl@0: // Without the Layout Engine sl@0: DisableShaping(&KNile8, textWithoutShaping ); sl@0: aGc.SetPenColor(KRgbBlack); sl@0: aGc.DrawText(textWithoutShaping, textRect3, baseLineOffset, CGraphicsContext::ELeft); sl@0: sl@0: aGc.SetPenColor(KRgbBlue); sl@0: aGc.DrawText(KNile8, textRect4, baseLineOffset, CGraphicsContext::ELeft); sl@0: //-------------------------------------------------------------------------- sl@0: // Without the Layout Engine sl@0: DisableShaping(&KNile9, textWithoutShaping ); sl@0: aGc.SetPenColor(KRgbBlack); sl@0: aGc.DrawText(textWithoutShaping, textRect5, baseLineOffset, CGraphicsContext::ELeft); sl@0: sl@0: aGc.SetPenColor(KRgbBlue); sl@0: aGc.DrawText(KNile9, textRect6, 100, CGraphicsContext::ELeft); sl@0: //-------------------------------------------------------------------------- sl@0: break; sl@0: sl@0: case 4: sl@0: // test sl@0: DisableShaping(&KTest1, textWithoutShaping ); sl@0: aGc.DrawText(textWithoutShaping, textRect, baseLineOffset, CGraphicsContext::ELeft); sl@0: sl@0: aGc.SetPenColor(KRgbBlue); sl@0: aGc.DrawText(KTest1, textRect2, baseLineOffset, CGraphicsContext::ELeft); sl@0: sl@0: //-------------------------------------------------------------------------- sl@0: // Without the Layout Engine sl@0: sl@0: aGc.SetPenColor(KRgbBlack); sl@0: DisableShaping(&KTest2, textWithoutShaping ); sl@0: aGc.DrawText(textWithoutShaping, textRect3, baseLineOffset, CGraphicsContext::ELeft); sl@0: // With the Layout Engine sl@0: sl@0: aGc.SetPenColor(KRgbBlue); sl@0: aGc.DrawText(KTest2, textRect4, baseLineOffset, CGraphicsContext::ELeft); sl@0: //-------------------------------------------------------------------------- sl@0: // Without the Layout Engine sl@0: sl@0: aGc.SetPenColor(KRgbBlack); sl@0: DisableShaping(&KTest3, textWithoutShaping ); sl@0: aGc.DrawText(textWithoutShaping, textRect5, baseLineOffset, CGraphicsContext::ELeft); sl@0: // With the Layout Engine sl@0: sl@0: aGc.SetPenColor(KRgbBlue); sl@0: aGc.DrawText(KTest3, textRect6, baseLineOffset, CGraphicsContext::ELeft); sl@0: //-------------------------------------------------------------------------- sl@0: sl@0: break; sl@0: } sl@0: sl@0: // Discard and destroy the font sl@0: aGc.DiscardFont(); sl@0: screenDevice->ReleaseFont(IndicFont); sl@0: sl@0: } sl@0: sl@0: sl@0: // ----------------------------------------------------------------------- sl@0: // Returns the number of controls in the control group. sl@0: // ----------------------------------------------------------------------- sl@0: TInt CMainViewContainer::CountComponentControls() const sl@0: { sl@0: return iCtrlArray.Count(); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------- sl@0: // Returns the component control identified by the given index sl@0: // ----------------------------------------------------------------------- sl@0: CCoeControl* CMainViewContainer::ComponentControl(TInt aIndex) const sl@0: { sl@0: return (CCoeControl*)iCtrlArray[aIndex]; sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------- sl@0: // Method invoked by control framework to handle key events sl@0: // ----------------------------------------------------------------------- sl@0: TKeyResponse CMainViewContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType) sl@0: { sl@0: if (HandleKeyEvents(aKeyEvent, aType)) sl@0: return EKeyWasConsumed; sl@0: else if(iFocusedControl) sl@0: return iFocusedControl->OfferKeyEventL(aKeyEvent, aType); sl@0: else sl@0: return EKeyWasNotConsumed; sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------- sl@0: // Method invoked to handle an event from an observed control sl@0: // ----------------------------------------------------------------------- sl@0: void CMainViewContainer::HandleControlEventL(CCoeControl * aControl, TCoeEvent aEventType) sl@0: { sl@0: DispatchControlEvents(aControl, aEventType); sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------- sl@0: // This method attemps to dispatch commands to individual handlers sl@0: // sl@0: // ----------------------------------------------------------------------- sl@0: bool CMainViewContainer::DispatchViewCommandEvents(TInt aCommand) sl@0: { sl@0: //InfoMessage sl@0: _LIT(message,"Copyright (c) 2006 Symbian Software Ltd.\n All rights reserved."); sl@0: switch (aCommand) sl@0: { sl@0: /* sample 1*/ sl@0: case 1009: sl@0: ChangeSample(1); sl@0: break; sl@0: /* sample 2*/ sl@0: case 1010: sl@0: ChangeSample(2); sl@0: break; sl@0: /* sample 3*/ sl@0: case 1011: sl@0: ChangeSample(3); sl@0: break; sl@0: /* sample 4*/ sl@0: case 1012: sl@0: ChangeSample(4); sl@0: break; sl@0: /* Font */ sl@0: case 1017: sl@0: ChangeFont(); sl@0: break; sl@0: case 1018: sl@0: ChangePreviousFont(); sl@0: break; sl@0: case 1020: sl@0: DisplayAvailableFonts(); sl@0: break; sl@0: case 1014: sl@0: // reduce font size sl@0: SetFontSize(GetFontSize() -20); sl@0: break; sl@0: case 1016: sl@0: // increase font size sl@0: SetFontSize(GetFontSize() +20); sl@0: break; sl@0: case 1015: sl@0: CAknInformationNote* informationNote = new (ELeave) CAknInformationNote; sl@0: informationNote->ExecuteLD(message); sl@0: break; sl@0: default: sl@0: // this command has not been processed by this view so.. sl@0: return false; sl@0: } sl@0: DrawDeferred(); sl@0: return true; sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------- sl@0: // Routine that attempts to dispatch Control Events sl@0: // sl@0: // ----------------------------------------------------------------------- sl@0: void CMainViewContainer::DispatchControlEvents(CCoeControl * /* aControl */, TCoeEvent /* aEventType */) sl@0: { sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------- sl@0: // Routine where you can handle key events sl@0: // ----------------------------------------------------------------------- sl@0: bool CMainViewContainer::HandleKeyEvents(const TKeyEvent& aKeyEvent, TEventCode /* aType */) sl@0: { sl@0: switch (aKeyEvent.iCode) sl@0: { sl@0: case EKeyUpArrow: sl@0: // increase font size sl@0: SetFontSize(GetFontSize() +20); sl@0: break; sl@0: case EKeyDownArrow: sl@0: // increase font size sl@0: SetFontSize(GetFontSize() -20); sl@0: break; sl@0: case EKeyLeftArrow: sl@0: // next sample sl@0: ChangeSample(GetSample()-1); sl@0: break; sl@0: case EKeyRightArrow: sl@0: // last sample sl@0: ChangeSample(GetSample()+1); sl@0: break; sl@0: case '8': sl@0: if (GetUnderLine() == EUnderlineOff) sl@0: SetUnderLine ( EUnderlineOn ); sl@0: else sl@0: SetUnderLine ( EUnderlineOff ); sl@0: break; sl@0: case '3': sl@0: ChangeFont(); sl@0: break; sl@0: case '1': sl@0: ChangePreviousFont(); sl@0: break; sl@0: default: sl@0: return false; sl@0: } sl@0: sl@0: DrawDeferred(); sl@0: return true; sl@0: } sl@0: sl@0: // ----------------------------------------------------------------------- sl@0: // Helper routine to manage Control Focus sl@0: // ----------------------------------------------------------------------- sl@0: void CMainViewContainer::ChangeFocus(CCoeControl * aNewControl) sl@0: { sl@0: if(iFocusedControl) sl@0: iFocusedControl->SetFocus(EFalse); sl@0: iFocusedControl = aNewControl; sl@0: if(iFocusedControl) sl@0: iFocusedControl->SetFocus(ETrue); sl@0: } sl@0: sl@0: