appfw/apparchitecture/tef/TAppEmbeddableUiNotStandAlone.cpp
changeset 0 2e3d3ce01487
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     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 // Supporting application for use by other test programs that need
       
    15 // to query the apparc server for applications which define
       
    16 // different embeddability values in their AIF files.
       
    17 // 
       
    18 //
       
    19 
       
    20 /**
       
    21  @file
       
    22  @internalComponent - Internal Symbian test code
       
    23 */
       
    24 
       
    25 #include <coeccntx.h>
       
    26 
       
    27 #include <apgtask.h>
       
    28 #include <eikenv.h>
       
    29 #include <eikappui.h>
       
    30 #include <eikapp.h>
       
    31 #include <eikdoc.h>
       
    32 #include <techview/eikmenup.h>
       
    33 
       
    34 #include "TAppEmbedUids.h"
       
    35 
       
    36 #include <ecom/ecom.h>
       
    37 #include <ecom/implementationproxy.h>
       
    38 
       
    39 _LIT(KExampleText, "This test application defines KAppEmbeddableUiNotStandAlone in it's AIF file");
       
    40 
       
    41 
       
    42 //
       
    43 //
       
    44 // CExampleAppView
       
    45 //
       
    46 //
       
    47 class CExampleAppView : public CCoeControl
       
    48     {
       
    49 public:
       
    50 	static CExampleAppView* NewL(const TRect& aRect);
       
    51 	CExampleAppView();
       
    52 	~CExampleAppView();
       
    53     void ConstructL(const TRect& aRect);
       
    54 
       
    55 private:
       
    56 	// from CCoeControl
       
    57 	void Draw(const TRect& /*aRect*/) const;
       
    58 private:
       
    59 	HBufC*  iExampleText;
       
    60     };
       
    61 
       
    62 CExampleAppView::CExampleAppView()
       
    63 	{
       
    64 	}
       
    65 
       
    66 CExampleAppView* CExampleAppView::NewL(const TRect& aRect)
       
    67 	{
       
    68 	CExampleAppView* self = new(ELeave) CExampleAppView();
       
    69 	CleanupStack::PushL(self);
       
    70 	self->ConstructL(aRect);
       
    71 	CleanupStack::Pop();
       
    72 	return self;
       
    73 	}
       
    74 
       
    75 CExampleAppView::~CExampleAppView()
       
    76 	{
       
    77 	delete iExampleText;
       
    78 	}
       
    79 
       
    80 void CExampleAppView::ConstructL(const TRect& aRect)
       
    81     {
       
    82 	TPtrC ptr(KExampleText);
       
    83 	iExampleText = ptr.AllocL();
       
    84 	CreateWindowL();
       
    85 	SetRect(aRect);
       
    86 	ActivateL();
       
    87 	}
       
    88 
       
    89 void CExampleAppView::Draw(const TRect& /*aRect*/) const
       
    90 	{
       
    91 	CWindowGc& gc = SystemGc();
       
    92 	TRect      drawRect = Rect();
       
    93 	const CFont*     fontUsed;
       
    94 	
       
    95 	gc.Clear();
       
    96   	fontUsed = iEikonEnv->TitleFont();
       
    97 	gc.UseFont(fontUsed);
       
    98 	TInt   baselineOffset=(drawRect.Height() - fontUsed->HeightInPixels())/2; 
       
    99 	gc.DrawText(*iExampleText,drawRect,baselineOffset,CGraphicsContext::ECenter, 0);
       
   100 	gc.DiscardFont();
       
   101 	}
       
   102 
       
   103 
       
   104 //
       
   105 //
       
   106 // CExampleAppUi
       
   107 //
       
   108 //
       
   109 class CExampleAppUi : public CEikAppUi
       
   110     {
       
   111 public:
       
   112     void ConstructL();
       
   113 	~CExampleAppUi();
       
   114 
       
   115 private:
       
   116     // from CEikAppUi
       
   117 	void HandleCommandL(TInt aCommand);
       
   118 private:
       
   119 	CCoeControl* iAppView;
       
   120 	};
       
   121 
       
   122 
       
   123 void CExampleAppUi::ConstructL()
       
   124     {
       
   125     BaseConstructL(ENoAppResourceFile | ENoScreenFurniture);
       
   126 	iAppView = CExampleAppView::NewL(ClientRect());
       
   127 	}
       
   128 
       
   129 CExampleAppUi::~CExampleAppUi()
       
   130 	{
       
   131 	delete iAppView;
       
   132 	}
       
   133 
       
   134 void CExampleAppUi::HandleCommandL(TInt aCommand)
       
   135 	{
       
   136 	switch (aCommand)
       
   137 		{
       
   138 	case EEikCmdExit: 
       
   139 		Exit();
       
   140 		break;
       
   141 		}
       
   142 	}
       
   143 
       
   144 
       
   145 //
       
   146 //
       
   147 // CExampleDocument
       
   148 //
       
   149 //
       
   150 class CExampleDocument : public CEikDocument
       
   151 	{
       
   152 public:
       
   153 	static CExampleDocument* NewL(CEikApplication& aApp);
       
   154 	CExampleDocument(CEikApplication& aApp);
       
   155 	void ConstructL();
       
   156 private: 
       
   157 	           // Inherited from CEikDocument
       
   158 	CEikAppUi* CreateAppUiL();
       
   159 	};
       
   160 
       
   161 CExampleDocument::CExampleDocument(CEikApplication& aApp)
       
   162 		: CEikDocument(aApp)
       
   163 	{
       
   164 	}
       
   165 
       
   166 CEikAppUi* CExampleDocument::CreateAppUiL()
       
   167 	{
       
   168     return new(ELeave) CExampleAppUi;
       
   169 	}
       
   170 
       
   171 
       
   172 
       
   173 //
       
   174 //
       
   175 // CExampleApplication
       
   176 //
       
   177 //
       
   178 
       
   179 class CExampleApplication : public CEikApplication
       
   180 	{
       
   181 private: 
       
   182 	// from CApaApplication
       
   183 	CApaDocument* CreateDocumentL();
       
   184 	TUid AppDllUid() const;
       
   185 private:
       
   186 	TFileName ResourceFileName() const;
       
   187 private:
       
   188 	CApaDocument* CreateDocumentL(CApaProcess* a) { return CEikApplication::CreateDocumentL(a); }
       
   189 	//
       
   190 	};
       
   191 
       
   192 CApaDocument* CExampleApplication::CreateDocumentL()
       
   193 	{
       
   194 	return new (ELeave) CExampleDocument(*this);
       
   195 	}
       
   196 
       
   197 TUid CExampleApplication::AppDllUid() const
       
   198 	{
       
   199 	return KUidAppEmbeddableUiNotStandAlone;
       
   200 	}
       
   201 
       
   202 TFileName CExampleApplication::ResourceFileName() const
       
   203 {
       
   204 	return TFileName(); // this app doesn't have a resource file
       
   205 }
       
   206 
       
   207 
       
   208 GLDEF_C TInt E32Dll(
       
   209 					)
       
   210 	{
       
   211 	return KErrNone;
       
   212 	}
       
   213 
       
   214 LOCAL_C CApaApplication* NewApplication()
       
   215 	{
       
   216 	return new CExampleApplication;
       
   217 	}
       
   218 
       
   219 LOCAL_D const TImplementationProxy ImplementationTable[]=
       
   220 	{
       
   221 	IMPLEMENTATION_PROXY_ENTRY(0x10004c4B, NewApplication)
       
   222 	};
       
   223 
       
   224 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
       
   225 	{
       
   226 	aTableCount=sizeof(ImplementationTable)/sizeof(ImplementationTable[0]);
       
   227 	return ImplementationTable;
       
   228 	}
       
   229