diff -r 000000000000 -r 2f259fa3e83a commonuisupport/uikon/test/tpackage/tembed.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/commonuisupport/uikon/test/tpackage/tembed.cpp Tue Feb 02 01:00:49 2010 +0200 @@ -0,0 +1,228 @@ +// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @internalComponent - Internal Symbian test code +*/ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include "tembed.hrh" + +#include "TEMBED.h" + +// +// CPackagerModel +// + +const TUid KUidEmbedApp={519}; + +void CViewControl::FocusChanged(TDrawNow /*aDrawNow*/) + { + } + +void CViewControl::ConstructL(const TRect& aRect) + { + CreateWindowL(); + Window().SetShadowDisabled(ETrue); + EnableDragEvents(); + iBrushStyle=CGraphicsContext::ESolidBrush; + //iBrushColor=KRgb1in4DitheredGray; + iContext=this; + Window().SetBackgroundColor(KRgb1in4DitheredGray); + SetRect(aRect); + TFontSpec spec(_L("Arial"),240); + iFont=iCoeEnv->CreateScreenFontL(spec); + + ActivateL(); + } + +CViewControl::~CViewControl() + { + iCoeEnv->ReleaseScreenFont(iFont); + } + +void CViewControl::Draw(const TRect& aRect) const + { + CGraphicsContext& gc=SystemGc(); + //gc.SetPenStyle(CGraphicsContext::ENullPen); + gc.DrawRect(aRect); + gc.UseFont(iFont); + + CEikAppUi *theApplication = (CEikAppUi*) (iCoeEnv->AppUi()); + CDocument* pDoc = (CDocument*)(theApplication->Document()); + + gc.DrawText(pDoc->iBuf, TPoint(10, 100)); + } + +void CViewControl::SizeChanged() + { + } + +TKeyResponse CViewControl::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) + { + if(aType!=EEventKey) + return(EKeyWasConsumed); + + CEikAppUi *theApplication = (CEikAppUi*) (iCoeEnv->AppUi()); + CDocument* pDoc = (CDocument*)(theApplication->Document()); + + switch(aKeyEvent.iCode) + { + case EKeyBackspace: + { + if(pDoc->iBuf.Length() > 0) + pDoc->iBuf.Delete(pDoc->iBuf.Length()-1 , 1); + } + break; + default: + pDoc->iBuf.Append(aKeyEvent.iCode); + break; + } + + + DrawNow(); + + return(EKeyWasConsumed); + } + +// +// CTestEmbedAppUi +// + +class CTestEmbedAppUi : public CEikAppUi + { +public: + void ConstructL(); + ~CTestEmbedAppUi(); +private: // from CEikAppUi + void HandleCommandL(TInt aCommand); +private: // internal functions + TInt SelectDocumentL(TInt aHelpRid,TInt aTitleRid); + void SendKeyEventToApplication(TKeyEvent theKeyEvent); +private: + CViewControl* iContainer; + }; + + +void CTestEmbedAppUi::ConstructL() + { + BaseConstructL(); + + iContainer=new(ELeave) CViewControl; + iContainer->ConstructL(ClientRect()); + AddToStackL(iContainer); + } + +CTestEmbedAppUi::~CTestEmbedAppUi() + { + if(iContainer) + RemoveFromStack(iContainer); + delete iContainer; + + } + +void CTestEmbedAppUi::HandleCommandL(TInt aCommand) + { + switch (aCommand) + { + case EEikCmdExit: + SaveAnyChangesL(); + Exit(); + break; + } + } + + +CEikAppUi* CDocument::CreateAppUiL() + { + return(new(ELeave) CTestEmbedAppUi); + } + + +// +// CEmbedApplication +// + +class CEmbedApplication : public CEikApplication + { +private: // from CApaApplication + CApaDocument* CreateDocumentL(); + TUid AppDllUid() const; +private: + CApaDocument* CreateDocumentL(CApaProcess* a) { return CEikApplication::CreateDocumentL(a); } + }; + +TUid CEmbedApplication::AppDllUid() const + { + return(KUidEmbedApp); + } + +CApaDocument* CEmbedApplication::CreateDocumentL() + { + return new(ELeave) CDocument(*this); + } + +// +// EXPORTed functions +// + + + +GLDEF_C TInt E32Dll( + ) + { + return KErrNone; + } + +LOCAL_C CApaApplication* NewApplication() + { + return new CEmbedApplication; + } + +LOCAL_D const TImplementationProxy ImplementationTable[]= + { + IMPLEMENTATION_PROXY_ENTRY(519, NewApplication) + }; + +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) + { + aTableCount=sizeof(ImplementationTable)/sizeof(ImplementationTable[0]); + return ImplementationTable; + } +