localisation/apparchitecture/tef/app_CTRL2.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 //
       
    15 
       
    16 
       
    17 
       
    18 /**
       
    19  @file
       
    20  @internalComponent - Internal Symbian test code 
       
    21 */
       
    22 
       
    23 #include <e32uid.h>
       
    24 #include <e32base.h>
       
    25 #include <e32test.h>
       
    26 #include <apgctl.h>
       
    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 #include <apgcli.h>
       
    37 
       
    38 #include <eikon.hrh>
       
    39 
       
    40 #include <App_CTRL2.rsg>
       
    41 #include "App_CTRL2.hrh"
       
    42 #include <eikstart.h>
       
    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 	           // Inherited from CCoeControl
       
    59 	void Draw(const TRect& /*aRect*/) const;
       
    60 
       
    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 	iExampleText = iEikonEnv->AllocReadResourceL(R_EXAMPLE_TEXT_TITLE);
       
    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 private:
       
   117               // Inherirted from class CEikAppUi
       
   118 	void HandleCommandL(TInt aCommand);
       
   119 
       
   120 	// From CCoeAppUi
       
   121 	void HandleSystemEventL(const TWsEvent& aEvent);
       
   122 
       
   123 private:
       
   124 	CCoeControl* iAppView;
       
   125 	};
       
   126 
       
   127 
       
   128 void CExampleAppUi::ConstructL()
       
   129     {
       
   130     BaseConstructL();
       
   131 	iAppView = CExampleAppView::NewL(ClientRect());
       
   132 	}
       
   133 
       
   134 CExampleAppUi::~CExampleAppUi()
       
   135 	{
       
   136 	delete iAppView;
       
   137 	}
       
   138 
       
   139 void CExampleAppUi::HandleCommandL(TInt aCommand)
       
   140 	{
       
   141 	switch (aCommand)
       
   142 		{
       
   143 		      // Just issue simple info messages to show that
       
   144 		      // the menu items have been selected
       
   145 	case EExampleItem0:
       
   146 		iEikonEnv->InfoMsg(R_EXAMPLE_TEXT_ITEM0);
       
   147 		break;
       
   148 
       
   149 	case EExampleItem1:
       
   150 		iEikonEnv->InfoMsg(R_EXAMPLE_TEXT_ITEM1);
       
   151 		break;
       
   152 	
       
   153 	case EExampleItem2:
       
   154 		iEikonEnv->InfoMsg(R_EXAMPLE_TEXT_ITEM2);
       
   155 		break;
       
   156 	case EEikCmdExit: 
       
   157 		Exit();
       
   158 		break;
       
   159 		}
       
   160 	}
       
   161 
       
   162 
       
   163 void CExampleAppUi::HandleSystemEventL(const TWsEvent& /*aEvent*/)
       
   164 	{
       
   165 	}
       
   166 
       
   167 ////////////////////////////////////////////////////////////////////////
       
   168 //
       
   169 // CExampleDocument
       
   170 //
       
   171 ////////////////////////////////////////////////////////////////////////
       
   172 class CExampleDocument : public CEikDocument
       
   173 	{
       
   174 public:
       
   175 	static CExampleDocument* NewL(CEikApplication& aApp);
       
   176 	CExampleDocument(CEikApplication& aApp);
       
   177 	void ConstructL();
       
   178 private: 
       
   179 	           // Inherited from CEikDocument
       
   180 	CEikAppUi* CreateAppUiL();
       
   181 	};
       
   182 
       
   183 CExampleDocument::CExampleDocument(CEikApplication& aApp)
       
   184 		: CEikDocument(aApp)
       
   185 	{
       
   186 	}
       
   187 
       
   188 CEikAppUi* CExampleDocument::CreateAppUiL()
       
   189 	{
       
   190     return new(ELeave) CExampleAppUi;
       
   191 	}
       
   192 
       
   193 
       
   194 
       
   195 ////////////////////////////////////////////////////////////////////////
       
   196 //
       
   197 // CExampleApplication
       
   198 //
       
   199 ////////////////////////////////////////////////////////////////////////
       
   200 
       
   201 class CExampleApplication : public CEikApplication
       
   202 	{
       
   203 private: 
       
   204 	           // Inherited from class CApaApplication
       
   205 	CApaDocument* CreateDocumentL();
       
   206 	TUid AppDllUid() const;
       
   207 private:
       
   208 	CApaDocument* CreateDocumentL(CApaProcess* a) { return CEikApplication::CreateDocumentL(a); }
       
   209 	//
       
   210 	};
       
   211 
       
   212 const TUid KUidSimpleApp = { 0x13008ADE }; 
       
   213 
       
   214 TUid CExampleApplication::AppDllUid() const
       
   215 	{
       
   216 	return KUidSimpleApp;
       
   217 	}
       
   218 
       
   219 CApaDocument* CExampleApplication::CreateDocumentL()
       
   220 	{
       
   221 	return new (ELeave) CExampleDocument(*this);
       
   222 	}
       
   223 
       
   224 
       
   225 LOCAL_C CApaApplication* NewApplication()
       
   226 	{
       
   227 	return new CExampleApplication;
       
   228 	}
       
   229 
       
   230 GLDEF_C TInt E32Main()
       
   231 	{
       
   232 	return EikStart::RunApplication(NewApplication);
       
   233 	}