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