commonuisupport/uikon/test/tpackage/tembed.cpp
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /**
       
    17  @file 
       
    18  @internalComponent - Internal Symbian test code 
       
    19 */
       
    20 
       
    21 
       
    22 #include <eikenv.h>
       
    23 #include <coecntrl.h>
       
    24 #include <basched.h>
       
    25 #include <coeccntx.h>
       
    26 #include <eikappui.h>
       
    27 #include <e32keys.h>
       
    28 #include <eikembal.h>
       
    29 #include <bamdesca.h>
       
    30 #include <techview/eikon.hrh>
       
    31 #include <techview/eikdialg.h>
       
    32 #include <techview/eikchlst.h>
       
    33 #include <eikdoc.h>
       
    34 #include <eikapp.h>
       
    35 #include <s32file.h>
       
    36 #include <techview/eikprtpv.h>
       
    37 #include <eikproc.h>
       
    38 #include <techview/eikon.rsg>
       
    39 #include <techview/eikmisdg.h>
       
    40 
       
    41 #include <ecom/ecom.h>
       
    42 #include <ecom/implementationproxy.h>
       
    43 
       
    44 #include <tembed.rsg>
       
    45 #include "tembed.hrh"
       
    46 
       
    47 #include "TEMBED.h"
       
    48 
       
    49 //
       
    50 // CPackagerModel
       
    51 //
       
    52 
       
    53 const TUid KUidEmbedApp={519};
       
    54 
       
    55 void CViewControl::FocusChanged(TDrawNow /*aDrawNow*/)
       
    56     {
       
    57     }
       
    58     
       
    59 void CViewControl::ConstructL(const TRect& aRect)
       
    60     {
       
    61 	CreateWindowL();
       
    62     Window().SetShadowDisabled(ETrue);
       
    63 	EnableDragEvents();
       
    64 	iBrushStyle=CGraphicsContext::ESolidBrush;
       
    65 	//iBrushColor=KRgb1in4DitheredGray;
       
    66     iContext=this;
       
    67 	Window().SetBackgroundColor(KRgb1in4DitheredGray);
       
    68     SetRect(aRect);
       
    69     TFontSpec spec(_L("Arial"),240);
       
    70     iFont=iCoeEnv->CreateScreenFontL(spec);
       
    71 	
       
    72 	ActivateL();
       
    73     }
       
    74 
       
    75 CViewControl::~CViewControl()
       
    76 	{
       
    77     iCoeEnv->ReleaseScreenFont(iFont);
       
    78 	}
       
    79 
       
    80 void CViewControl::Draw(const TRect& aRect) const
       
    81     {
       
    82 	CGraphicsContext& gc=SystemGc();
       
    83 	//gc.SetPenStyle(CGraphicsContext::ENullPen);
       
    84 	gc.DrawRect(aRect);
       
    85 	gc.UseFont(iFont);
       
    86 	
       
    87 	CEikAppUi *theApplication = (CEikAppUi*) (iCoeEnv->AppUi());
       
    88 	CDocument*	pDoc = (CDocument*)(theApplication->Document());
       
    89 
       
    90 	gc.DrawText(pDoc->iBuf, TPoint(10, 100));
       
    91     }
       
    92 
       
    93 void CViewControl::SizeChanged()
       
    94     {
       
    95     }
       
    96 
       
    97 TKeyResponse CViewControl::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
       
    98     {
       
    99     if(aType!=EEventKey)
       
   100 		return(EKeyWasConsumed);
       
   101 	
       
   102 	CEikAppUi *theApplication = (CEikAppUi*) (iCoeEnv->AppUi());
       
   103 	CDocument*	pDoc = (CDocument*)(theApplication->Document());
       
   104 	
       
   105 	switch(aKeyEvent.iCode)
       
   106 		{
       
   107 		case EKeyBackspace:
       
   108 			{
       
   109 			if(pDoc->iBuf.Length() > 0)
       
   110 				pDoc->iBuf.Delete(pDoc->iBuf.Length()-1 , 1);
       
   111 			}
       
   112 		break;
       
   113 		default:
       
   114 			pDoc->iBuf.Append(aKeyEvent.iCode);
       
   115 			break;
       
   116 		}
       
   117 	
       
   118 	
       
   119 	DrawNow();
       
   120 	
       
   121 	return(EKeyWasConsumed);
       
   122     }
       
   123 
       
   124 //
       
   125 // CTestEmbedAppUi
       
   126 //
       
   127 
       
   128 class CTestEmbedAppUi : public CEikAppUi
       
   129     {
       
   130 public:
       
   131     void ConstructL();
       
   132 	~CTestEmbedAppUi();
       
   133 private: // from CEikAppUi
       
   134     void HandleCommandL(TInt aCommand);
       
   135 private: // internal functions
       
   136 	TInt SelectDocumentL(TInt aHelpRid,TInt aTitleRid);
       
   137 	void SendKeyEventToApplication(TKeyEvent	theKeyEvent);
       
   138 private:
       
   139     CViewControl* iContainer;
       
   140     };
       
   141 
       
   142 
       
   143 void CTestEmbedAppUi::ConstructL()
       
   144     {
       
   145     BaseConstructL();
       
   146     
       
   147 	iContainer=new(ELeave) CViewControl;
       
   148     iContainer->ConstructL(ClientRect());
       
   149     AddToStackL(iContainer);
       
   150     }
       
   151 
       
   152 CTestEmbedAppUi::~CTestEmbedAppUi()
       
   153 	{
       
   154 	if(iContainer)
       
   155 		RemoveFromStack(iContainer);
       
   156     delete iContainer;
       
   157 
       
   158 	}
       
   159 
       
   160 void CTestEmbedAppUi::HandleCommandL(TInt aCommand)
       
   161     {
       
   162 	switch (aCommand)
       
   163 		{
       
   164 	case EEikCmdExit:
       
   165 		SaveAnyChangesL();
       
   166         Exit();
       
   167 		break;
       
   168 		}
       
   169     }
       
   170 
       
   171 
       
   172 CEikAppUi* CDocument::CreateAppUiL()
       
   173 	{
       
   174     return(new(ELeave) CTestEmbedAppUi);
       
   175 	}
       
   176 
       
   177 
       
   178 //
       
   179 // CEmbedApplication
       
   180 //
       
   181 
       
   182 class CEmbedApplication : public CEikApplication
       
   183 	{
       
   184 private: // from CApaApplication
       
   185 	CApaDocument* CreateDocumentL();
       
   186 	TUid AppDllUid() const;
       
   187 private:
       
   188 	CApaDocument* CreateDocumentL(CApaProcess* a) { return CEikApplication::CreateDocumentL(a); }
       
   189 	};
       
   190 
       
   191 TUid CEmbedApplication::AppDllUid() const
       
   192 	{
       
   193 	return(KUidEmbedApp);
       
   194 	}
       
   195 
       
   196 CApaDocument* CEmbedApplication::CreateDocumentL()
       
   197 	{
       
   198 	return new(ELeave) CDocument(*this);
       
   199 	}
       
   200 
       
   201 //
       
   202 // EXPORTed functions
       
   203 //
       
   204 
       
   205 
       
   206 
       
   207 GLDEF_C TInt E32Dll(
       
   208 					)
       
   209 	{
       
   210 	return KErrNone;
       
   211 	}
       
   212 
       
   213 LOCAL_C CApaApplication* NewApplication()
       
   214 	{
       
   215 	return new CEmbedApplication;
       
   216 	}
       
   217 
       
   218 LOCAL_D const TImplementationProxy ImplementationTable[]=
       
   219 	{
       
   220 	IMPLEMENTATION_PROXY_ENTRY(519, NewApplication)
       
   221 	};
       
   222 
       
   223 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
       
   224 	{
       
   225 	aTableCount=sizeof(ImplementationTable)/sizeof(ImplementationTable[0]);
       
   226 	return ImplementationTable;
       
   227 	}
       
   228