creatinfoview.cpp

来自「symbian 3nd 实现短信息收发」· C++ 代码 · 共 176 行

CPP
176
字号
/*
* ============================================================================
*  Name     : CCreatInfoView from CAknView
*  Part of  : CreatInfo
*  Copyright (c) 2003 Nokia. All rights reserved.
* ============================================================================
*/

// INCLUDE FILES
#include <aknviewappui.h>
#include <avkon.hrh>
#include <akntitle.h>
#include <FrMes.rsg>
#include "FrMes.hrh"
#include "CreatInfoView.h"
#include "CreatInfoContainer.h"
#include <aknnotewrappers.h>
#include "FrMesAppUi.h"
#include "FrMesDB.h"

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

// C++ default constructor can NOT contain any code, that
// might leave.
//
CCreatInfoView* CCreatInfoView::NewL()
{
    CCreatInfoView* self = NewLC();
    CleanupStack::Pop(self);
    return self;
}

CCreatInfoView* CCreatInfoView::NewLC()
{
    CCreatInfoView* self = new (ELeave) CCreatInfoView;
    CleanupStack::PushL(self);
    self->ConstructL();
    return self;
}

CCreatInfoView::CCreatInfoView()
{
}

// EPOC default constructor can leave.
void CCreatInfoView::ConstructL()
{
    BaseConstructL(R_CREATE_VIEW);
}

// Destructor
CCreatInfoView::~CCreatInfoView()
{
    if (iContainer)
	{
        AppUi()->RemoveFromStack(iContainer);
	}
	
    delete iContainer;
}

// ---------------------------------------------------------
// TUid CCreatInfoView::Id()
// Returns Id of the view.
// ---------------------------------------------------------
TUid CCreatInfoView::Id() const
{
    return KCreatInfoViewId;
}

// ---------------------------------------------------------
// CCreatInfoView::HandleCommandL(TInt aCommand)
// Handles commands
// ---------------------------------------------------------
void CCreatInfoView::HandleCommandL(TInt aCommand)
{
switch(aCommand)
	{
	case EAknSoftkeyOk:
		{
			TBuf<16> sTmpName;
			TBuf<16> sTmpCode;
			iContainer->GetInput(sTmpName,sTmpCode);
			if(sTmpName.Length()==0)
			{
				TBuf<32> sTmp;
				CEikonEnv::Static()->ReadResource(sTmp, R_QTN_FRMES_ERROR_CNAME);
				CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
				informationNote->ExecuteLD(sTmp);
				return;
			}
			else
			{
				if(sTmpCode.Length()==0)
				{
					TBuf<64> sTmp;
					CEikonEnv::Static()->ReadResource(sTmp, R_QTN_FRMES_ERROR_CCODE);
					CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
					informationNote->ExecuteLD(sTmp);
					return;
				}
				else
				{
					AddInfoL(sTmpName,sTmpCode);
					AppUi()->HandleCommandL(aCommand);
				}
			}		
		}
		break;

	default:
		AppUi()->HandleCommandL(aCommand);
		break;
	}
}

// ---------------------------------------------------------
// CCreatInfoView::HandleClientRectChange()
// Handles client rect change.
// ---------------------------------------------------------
void CCreatInfoView::HandleClientRectChange()
{
    if (iContainer)
	{
        iContainer->SetRect(ClientRect());
	}
}

// ---------------------------------------------------------
// CCreatInfoView::DoActivateL(...)
// Creates the Container class object.
// ---------------------------------------------------------
void CCreatInfoView::DoActivateL(const TVwsViewId& /*aPrevViewId*/,
								 TUid /*aCustomMessageId*/,
								 const TDesC8& /*aCustomMessage*/)
{
    iContainer = new (ELeave) CCreatInfoContainer;
    iContainer->SetMopParent(this);
	//===============================modify cba by wzg===============
	TRect rc;
	rc.SetRect(ClientRect().iTl, TSize(176, 144));
	iContainer->ConstructL(rc);
	AppUi()->AddToStackL(*this, iContainer);
	
	//modify title by wzg
	TBuf<32> sTmpTitle;
	CEikStatusPane* statusPane = StatusPane();
	CEikonEnv::Static()->ReadResource(sTmpTitle,R_FRMES_VIEW_TITLE_CREATEINFO);
	CAknTitlePane* titlePane = (CAknTitlePane*) statusPane->ControlL(TUid::Uid(EEikStatusPaneUidTitle));
	titlePane->SetTextL(sTmpTitle);
}

// ---------------------------------------------------------
// CCreatInfoView::DoDeactivate()
// Deletes the Container class object.
// ---------------------------------------------------------
void CCreatInfoView::DoDeactivate()
{
    if (iContainer)
	{
        AppUi()->RemoveFromStack(iContainer);
	}
    
    delete iContainer;
    iContainer = NULL;
}

void CCreatInfoView::AddInfoL(TDes& aName, TDes& aCode)
{
	CFrMesAppUi* pApp = (CFrMesAppUi*)CEikonEnv::Static()->AppUi();
	pApp->m_pDB->AddInfoL(aName,aCode);
}

// End of File

⌨️ 快捷键说明

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