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