www.pudn.com > UIQ_Code1.rar > CommandsHandlerPage2.cpp


// CommandsHandlerPage2.cpp 
// 
// © Symbian Software Ltd 2005. All rights reserved. 
// 
 
#include "CommandsHandlerPage2.h" 
#include "CommandsView.h" 
#include "Commands.hrh" 
 
#include  
 
/** 
Creates and constructs the command handler for page 2. 
 
@param aCommandView Reference to the CCommandsView 
@return Pointer to a CCommandsHandlerPage2 object 
*/ 
CCommandsHandlerPage2* CCommandsHandlerPage2::NewL(CCommandsView& aCommandsView, CQikCommandManager& aCommandManager) 
	{ 
	CCommandsHandlerPage2* self = new(ELeave) CCommandsHandlerPage2(aCommandsView, aCommandManager); 
	CleanupStack::PushL(self); 
	self->ConstructL(); 
	CleanupStack::Pop(self); 
	return self; 
	} 
	 
/** 
Constructor for the model. Adds the references to the command manager and  
command view.  
 
@param aCommandsView Reference to the CCommandsView 
*/ 
CCommandsHandlerPage2::CCommandsHandlerPage2(CCommandsView& aCommandsView, CQikCommandManager& aCommandManager) 
	: iCommandManager(aCommandManager), iCommandsView(aCommandsView) 
	{ 
	} 
 
/** 
2nd stage construction of the model. 
Creates the command state monitor that initialized all states to 0. 
Changes the values for the state properties for applicationState1 and  
applicationState2. 
*/ 
void CCommandsHandlerPage2::ConstructL() 
	{ 
	} 
 
/** 
Destructor for the model. Deletes the command state monitor. 
*/ 
CCommandsHandlerPage2::~CCommandsHandlerPage2() 
	{ 
	} 
	 
/** 
The purpose of page2 commands is to show usage of option button list  
and cascading menu. 
 
If a cascading menu (also called named group) only contains dimmed 
/invisible commands, the command itself that holds the cascading menu will also 
be made dimmed/invisible by the framework.  
 
Whether dimming or visibility is used will be determined by the  
phone style (pen style dimm commands while softkey style makes them  
invisible). Applications can stick to use SetAvailable() which will  
encapsulate the difference between different phone styles. 
 
If you dimm a cascading menu command, all commands in that named group will be 
auto-dimmed. You only have to undim the cascading menu command to have the  
group members auto-undimmed. The same functionality also exists in softkey  
style user interfaces, but in softkey style the framework auto-hide/unhide  
instead of dimm. 
 
@param aCommand The command to be executed 
*/ 
void CCommandsHandlerPage2::HandleCommandL(CQikCommand& aCommand) 
	{ 
	// Launch an infoprint with the command text  
	iCommandsView.InfoprintCmdL(aCommand); 
	 
	switch(aCommand.Id()) 
		{ 
		case ECommandsPage2CacscadingAvailableCmd: 
			{ 
			// Get the checkbox state 
			const TBool checked = aCommand.Checked(); 
 
			// Sets the availability for the cascading menu command, all  
			// commands in that named group will be unavailable. When the  
			// cascading menu command sets available all commands in the named  
			// group will be available according there own state again. 
			iCommandManager.SetAvailable(iCommandsView, ECommandsPage2CascadeCmd, checked); 
			break; 
			} 
		case ECommandsPage2AllOffCmd: 
			{ 
			// All commands in the cascading menu is made unavailable which will  
			// result in dimmed/invisible commands, the cascading menu command  
			// will also be made dimmed/invisible by the framework.  
			iCommandManager.SetAvailable(iCommandsView, ECommandsPage2CmdECmd, EFalse); 
			iCommandManager.SetAvailable(iCommandsView, ECommandsPage2CmdFCmd, EFalse); 
			break; 
			} 
		case ECommandsPage2CmdEAvailableCmd: 
			{ 
			// Sets "Cmd E" available and "Cmd F" unavailable. 
			iCommandManager.SetAvailable(iCommandsView, ECommandsPage2CmdECmd, ETrue); 
			iCommandManager.SetAvailable(iCommandsView, ECommandsPage2CmdFCmd, EFalse); 
			break; 
			} 
		case ECommandsPage2CmdFAvailableCmd: 
			{ 
			// Sets "Cmd E" unavailable and "Cmd F" available. 
			iCommandManager.SetAvailable(iCommandsView, ECommandsPage2CmdECmd, EFalse); 
			iCommandManager.SetAvailable(iCommandsView, ECommandsPage2CmdFCmd, ETrue); 
			break; 
			} 
		case ECommandsPage2CmdEAndFAvailableCmd: 
			{ 
			// Sets all cascade item to available. 
			iCommandManager.SetAvailable(iCommandsView, ECommandsPage2CmdECmd, ETrue); 
			iCommandManager.SetAvailable(iCommandsView, ECommandsPage2CmdFCmd, ETrue); 
			break; 
			} 
		case ECommandsPage2CmdECmd: 
		case ECommandsPage2CmdFCmd: 
			{ 
			// Do nothing. In a normal application something should happen  
			// here when the command has been activated.  
			// If commands are not handle by the view they will be propageted  
			// to the appUi.  
			break; 
			} 
		case ECommandsPage2CascadeCmd: 
			{ 
			// Do nothing. The command's purpose is to launch a cascading menu 
			// for command E and F. This is done by the framework. 
			break; 
			} 
		default: 
			{ 
			iCommandsView.HandleCommandL(aCommand); 
			break; 
			} 
		} 
	}