////////////////////////////////////////////////////////////////////////
//
// Source file for the implementation of the 
// application UI class - C${PrjName}AppUi
//
////////////////////////////////////////////////////////////////////////

// To enable the dynamic loading of the menu with a Close command in the UDEB version
#include <eikmenub.h>

#include "${PrjName}.h"

//             The second phase constructor of the application UI class.
//             The application UI creates and owns the one and only view.
// 
void C${PrjName}AppUi::ConstructL()
    {
	           // BaseConstructL() completes the UI framework's
	           // construction of the App UI.
    BaseConstructL();
	           // Create the single application view in which to
	           // draw the text "Hello World!", passing into it
	           // the rectangle available to it.
	iAppView = C${PrjName}AppView::NewL(ClientRect());
	}


//             The app Ui owns the two views and is. 
//             therefore, responsible for destroying them
//
C${PrjName}AppUi::~C${PrjName}AppUi()
	{
	delete iAppView;
	}


//             Called by the UI framework when a command has been issued.
//             In this example, a command can originate through a 
//             hot-key press or by selection of a menu item.
//             The command Ids are defined in the .hrh file
//             and are 'connected' to the hot-key and menu item in the
//             resource file.
//             Note that the EEikCmdExit is defined by the UI
//             framework and is pulled in by including eikon.hrh
//
void C${PrjName}AppUi::HandleCommandL(TInt aCommand)
	{
	switch (aCommand)
		{
		      // Just issue simple info messages to show that
		      // the menu items have been selected
	case E${PrjName}Item0:
		iEikonEnv->InfoMsg(R_${PrjName:uppercase}_TEXT_ITEM0);
		break;

	
	case E${PrjName}Item1:
		iEikonEnv->InfoMsg(R_${PrjName:uppercase}_TEXT_ITEM1);
		break;
	
	case E${PrjName}Item2:
		iEikonEnv->InfoMsg(R_${PrjName:uppercase}_TEXT_ITEM2);
		break;
               // Exit the application. The call is
		       // implemented by the UI framework.

	case EEikCmdExit: 
		Exit();
		break;
		}
	}


// This is a way to dynamically initialize the menu.
// If it is the debug version, the menu should contain a Close command.
// In the release version, there should be no Close command.
#if defined(_DEBUG)
void C${PrjName}AppUi::DynInitMenuPaneL(TInt aMenuId, CEikMenuPane* aMenuPane)
	{
	if(aMenuId == R_${PrjName:uppercase}_FIRST_MENU)
		{
		CEikMenuPaneItem::SData itemData;
		TBuf<16> closeCommandText;
		iEikonEnv->ReadResource(closeCommandText, R_${PrjName:uppercase}_CLOSE_COMMAND);
		itemData.iText=closeCommandText;
		itemData.iCommandId=EEikCmdExit;
		itemData.iFlags=0;
		itemData.iCascadeId=0;
		aMenuPane->AddMenuItemL(itemData);
		}
	}
#endif
