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