⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 systemagentdialog.cpp

📁 最新官方例子,图形,描述副,基本控件,通讯协议,等等,
💻 CPP
字号:
/**
* 
* @brief Definition of CSystemAgentDialog
*
* Copyright (c) EMCC Software Ltd 2003
* @version 1.0
*/

// INCLUDE FILES

// Class include
#include "SystemAgentDialog.h"
#include "systemagent.hrh"

// System includes
#include <aknappui.h>	// iAvkonAppUi
#include <avkon.hrh>	// EAknSoftkeyBack, EEikCmdExit
#include <eikedwin.h>	// CEikEdwin
#include <stringloader.h>
#include <SystemAgent.rsg>
#include <sacls.h>

// User includes
#include "SystemAgentDocument.h"

// ================= MEMBER FUNCTIONS =======================

/**
 * Sets the text in the control on the specified line of the dialog
 */
void CSystemAgentDialog::SetTextL(TSystemAgentDlgLineId aLine, const TDesC& aText)
	{
	CEikEdwin* control = static_cast<CEikEdwin*>(Control(aLine));
	control->SetTextL(&aText);
	control->DrawDeferred();
	}

/**
 * Sets the text in the appropriate dialog line for the specified state variable
 */
void CSystemAgentDialog::ProcessStateVarChangeL(TUid aStateVarUid, TInt aNewState)
	{
	// The text for the line has a parameter which is specified by the state text
	TInt stateTextId = R_INVALID_TEXT;

	// The ID of the line in the dialog corresponding to aStateVarUid
	TSystemAgentDlgLineId dlgLineId = ESystemAgentDlgSystemAgentStateLabel;

	// A negative state indicates error for all State Variables
	if (aNewState < 0)
		stateTextId = R_ERROR_TEXT;

	// Workout which label and state strings correspond with the new state
	if (aStateVarUid == KUidSystemAgentStateVariable)
		{
		dlgLineId = ESystemAgentDlgSystemAgentStateLabel;
		switch (aNewState)
			{
			case CSystemAgentDocument::ESystemAgentRed:
				stateTextId = R_SYSTEMAGENT_RED_TEXT;
				break;
			case CSystemAgentDocument::ESystemAgentGreen:
				stateTextId = R_SYSTEMAGENT_GREEN_TEXT;
				break;
			case CSystemAgentDocument::ESystemAgentBlue:
				stateTextId = R_SYSTEMAGENT_BLUE_TEXT;
				break;
			}
		}
	else if (aStateVarUid == KUidInboxStatus)
		{
		dlgLineId = ESystemAgentDlgInboxStateLabel;

		switch (aNewState)
			{
			case ESAInboxEmpty:
				stateTextId = R_INBOX_NONEWMESSAGES_TEXT;
				break;
			case ESADocumentsInInbox:
				stateTextId = R_INBOX_NEWMESSAGES_TEXT;
				break;
			}
		}
	else if (aStateVarUid == KUidChargerStatus)
		{
		dlgLineId = ESystemAgentDlgChargerStateLabel;

		switch (aNewState)
			{
			case ESAChargerConnected:
				stateTextId = R_CHARGER_CHARGING_TEXT;
				break;
			case ESAChargerDisconnected:
				stateTextId = R_CHARGER_DISCONNECTED_TEXT;
				break;
			case ESAChargerNotCharging:
				stateTextId = R_CHARGER_NOTCHARGING_TEXT;
				break;
			}
		}
	else if (aStateVarUid == KUidNetworkStrength)
		{
		dlgLineId = ESystemAgentDlgNetworkStrengthStateLabel;

		switch (aNewState)
			{
			case ESANetworkStrengthNone:
				stateTextId = R_NETWORKSTRENGTH_NONE_TEXT;
				break;
			case ESANetworkStrengthLow:
				stateTextId = R_NETWORKSTRENGTH_LOW_TEXT;
				break;
			case ESANetworkStrengthMedium:
				stateTextId = R_NETWORKSTRENGTH_MEDIUM_TEXT;
				break;
			case ESANetworkStrengthHigh:
				stateTextId = R_NETWORKSTRENGTH_HIGH_TEXT;
				break;
			case ESANetworkStrengthUnknown:
				stateTextId = R_NETWORKSTRENGTH_UNKNOWN_TEXT;
				break;
			}
		}

	// Load the state text
	HBufC* stateText = StringLoader::LoadLC(stateTextId);					// Buffer on cleanup stack

	// Set the text in the appropriate line
	SetTextL(dlgLineId, *stateText);

	CleanupStack::PopAndDestroy(stateText);
	}


/**
* Called by the framework when a button is pressed.
* Translates aButtonId into a command for the AppUi to handle
* @param aButtonId The button which was pressed
*/
TBool CSystemAgentDialog::OkToExitL(TInt aButtonId)
	{
	// Translate the button presses into commands for the appui & current
	// view to handle
	if (aButtonId == EAknSoftkeyExit)
		{
		// Causes this dialog to be deleted (and never returns..)
		iAvkonAppUi->ProcessCommandL(EEikCmdExit);
		}
	else if (aButtonId == EAknSoftkeyOptions)
		{
		iAvkonAppUi->ProcessCommandL(EAknSoftkeyOptions);
		}

	return EFalse;		// Never "OK to exit" here - UI destroys dialog in its destructor
	}


// End of File

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -