localisation/apparchitecture/tef/M_CTRL_V2.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 
       
    24 #include <e32uid.h>
       
    25 #include <e32base.h>
       
    26 #include <e32test.h>
       
    27 #include <apgctl.h>
       
    28 
       
    29 #include <eikdll.h>
       
    30 #include <coeccntx.h>
       
    31 #include <apgtask.h>
       
    32 #include <eikenv.h>
       
    33 #include <eikappui.h>
       
    34 #include <eikapp.h>
       
    35 #include <eikdoc.h>
       
    36 #include <eikmenup.h>
       
    37 #include <apgcli.h>
       
    38 
       
    39 #include <eikon.hrh>
       
    40 //#include "appfwk_test_AppUi.h"
       
    41 
       
    42 #include <M_CTRL.rsg>
       
    43 #include "M_CTRL.hrh"
       
    44 #include <EIKDLL.H>
       
    45 #include <eikstart.h>
       
    46 
       
    47 
       
    48 //const TInt KMinimalControlUidValue=98;
       
    49 //const TInt KMinimalControlUidValue=0x13008AEE;	//Changed in m_ctrl.mmp file
       
    50 
       
    51 //_LIT(KGlobalSemaphore, "GlobalSemaphore");
       
    52 
       
    53 
       
    54 ////////////////////////////////////////////////////////////////////////
       
    55 //
       
    56 // CExampleAppView
       
    57 //
       
    58 ////////////////////////////////////////////////////////////////////////
       
    59 class CExampleAppView : public CCoeControl
       
    60     {
       
    61 public:
       
    62 	static CExampleAppView* NewL(const TRect& aRect);
       
    63 	CExampleAppView();
       
    64 	~CExampleAppView();
       
    65     void ConstructL(const TRect& aRect);
       
    66 
       
    67 private:
       
    68 	           // Inherited from CCoeControl
       
    69 	void Draw(const TRect& /*aRect*/) const;
       
    70 
       
    71 private:
       
    72 	HBufC*  iExampleText;
       
    73     };
       
    74 
       
    75 CExampleAppView::CExampleAppView()
       
    76 	{
       
    77 	}
       
    78 
       
    79 CExampleAppView* CExampleAppView::NewL(const TRect& aRect)
       
    80 	{
       
    81 	CExampleAppView* self = new(ELeave) CExampleAppView();
       
    82 	CleanupStack::PushL(self);
       
    83 	self->ConstructL(aRect);
       
    84 	CleanupStack::Pop();
       
    85 	return self;
       
    86 	}
       
    87 
       
    88 CExampleAppView::~CExampleAppView()
       
    89 	{
       
    90 	delete iExampleText;
       
    91 	}
       
    92 
       
    93 void CExampleAppView::ConstructL(const TRect& aRect)
       
    94     {
       
    95 	iExampleText = iEikonEnv->AllocReadResourceL(R_EXAMPLE_TEXT_TITLE);
       
    96 	CreateWindowL();
       
    97 	SetRect(aRect);
       
    98 	ActivateL();
       
    99 	}
       
   100 
       
   101 void CExampleAppView::Draw(const TRect& /*aRect*/) const
       
   102 	{
       
   103 	CWindowGc& gc = SystemGc();
       
   104 	TRect      drawRect = Rect();
       
   105 	const CFont*     fontUsed;
       
   106 	
       
   107 	gc.Clear();
       
   108   	fontUsed = iEikonEnv->TitleFont();
       
   109 	gc.UseFont(fontUsed);
       
   110 	TInt   baselineOffset=(drawRect.Height() - fontUsed->HeightInPixels())/2; 
       
   111 	gc.DrawText(*iExampleText,drawRect,baselineOffset,CGraphicsContext::ECenter, 0);
       
   112 	gc.DiscardFont();
       
   113 	}
       
   114 
       
   115 
       
   116 ////////////////////////////////////////////////////////////////////////
       
   117 //
       
   118 // CExampleAppUi
       
   119 //
       
   120 ////////////////////////////////////////////////////////////////////////
       
   121 class CExampleAppUi : public CEikAppUi
       
   122     {
       
   123 public:
       
   124     void ConstructL();
       
   125 	~CExampleAppUi();
       
   126 private:
       
   127               // Inherirted from class CEikAppUi
       
   128 	void HandleCommandL(TInt aCommand);
       
   129 
       
   130 	// From CCoeAppUi
       
   131 	void HandleSystemEventL(const TWsEvent& aEvent);
       
   132 
       
   133 private:
       
   134 	CCoeControl* iAppView;
       
   135 	};
       
   136 
       
   137 
       
   138 void CExampleAppUi::ConstructL()
       
   139     {
       
   140     BaseConstructL();
       
   141 	iAppView = CExampleAppView::NewL(ClientRect());
       
   142 	}
       
   143 
       
   144 CExampleAppUi::~CExampleAppUi()
       
   145 	{
       
   146 	delete iAppView;
       
   147 	}
       
   148 
       
   149 void CExampleAppUi::HandleCommandL(TInt aCommand)
       
   150 	{
       
   151 	switch (aCommand)
       
   152 		{
       
   153 	// Just issue simple info messages to show that
       
   154 	// the menu items have been selected
       
   155 	case EExampleItem0:
       
   156 		iEikonEnv->InfoMsg(R_EXAMPLE_TEXT_ITEM0);
       
   157 		break;
       
   158 
       
   159 	case EExampleItem1:
       
   160 		iEikonEnv->InfoMsg(R_EXAMPLE_TEXT_ITEM1);
       
   161 		break;
       
   162 	
       
   163 	case EExampleItem2:
       
   164 		iEikonEnv->InfoMsg(R_EXAMPLE_TEXT_ITEM2);
       
   165 		break;
       
   166 	case EEikCmdExit: 
       
   167 		Exit();
       
   168 		break;
       
   169 		}
       
   170 	}
       
   171 
       
   172 
       
   173 void CExampleAppUi::HandleSystemEventL(const TWsEvent& /*aEvent*/)
       
   174 	{
       
   175 /*
       
   176 	RSemaphore semaphore;
       
   177 	
       
   178 	switch (*(TApaSystemEvent*)(aEvent.EventData()))
       
   179 		{
       
   180 
       
   181 		case EApaSystemEventBroughtToForeground:
       
   182 			{	
       
   183 			semaphore.OpenGlobal(KGlobalSemaphore);
       
   184 			semaphore.Signal();
       
   185 			semaphore.Close();
       
   186             break;
       
   187 			}
       
   188          default:
       
   189 			break;
       
   190 			}	
       
   191 */
       
   192 	}
       
   193 
       
   194 
       
   195 
       
   196 
       
   197 ////////////////////////////////////////////////////////////////////////
       
   198 //
       
   199 // CExampleDocument
       
   200 //
       
   201 ////////////////////////////////////////////////////////////////////////
       
   202 class CExampleDocument : public CEikDocument
       
   203 	{
       
   204 public:
       
   205 	static CExampleDocument* NewL(CEikApplication& aApp);
       
   206 	CExampleDocument(CEikApplication& aApp);
       
   207 	void ConstructL();
       
   208 private: 
       
   209 	           // Inherited from CEikDocument
       
   210 	CEikAppUi* CreateAppUiL();
       
   211 	};
       
   212 
       
   213 CExampleDocument::CExampleDocument(CEikApplication& aApp)
       
   214 		: CEikDocument(aApp)
       
   215 	{
       
   216 	}
       
   217 
       
   218 CEikAppUi* CExampleDocument::CreateAppUiL()
       
   219 	{
       
   220     return new(ELeave) CExampleAppUi;
       
   221 	}
       
   222 
       
   223 
       
   224 
       
   225 ////////////////////////////////////////////////////////////////////////
       
   226 //
       
   227 // CExampleApplication
       
   228 //
       
   229 ////////////////////////////////////////////////////////////////////////
       
   230 
       
   231 class CExampleApplication : public CEikApplication
       
   232 	{
       
   233 private: 
       
   234 	           // Inherited from class CApaApplication
       
   235 	CApaDocument* CreateDocumentL();
       
   236 	TUid AppDllUid() const;
       
   237 private:
       
   238 	CApaDocument* CreateDocumentL(CApaProcess* a) { return CEikApplication::CreateDocumentL(a); }
       
   239 	//
       
   240 	};
       
   241 
       
   242 const TUid KUidSimpleApp = { 0x13008AEE }; 
       
   243 
       
   244 TUid CExampleApplication::AppDllUid() const
       
   245 	{
       
   246 	return KUidSimpleApp;
       
   247 	}
       
   248 
       
   249 CApaDocument* CExampleApplication::CreateDocumentL()
       
   250 	{
       
   251 	return new (ELeave) CExampleDocument(*this);
       
   252 	}
       
   253 
       
   254 
       
   255 LOCAL_C CApaApplication* NewApplication()
       
   256 	{
       
   257 	return new CExampleApplication;
       
   258 	}
       
   259 	
       
   260 GLDEF_C TInt E32Main()
       
   261 	{
       
   262 	return EikStart::RunApplication(NewApplication);
       
   263 	}
       
   264