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

📄 logincontainer.cpp

📁 symbian手机加密记事本
💻 CPP
字号:
/*
* ============================================================================
*  Name     : CLoginContainer from CCoeControl, MCoeControlObserver
*  Part of  : Login
*  Copyright (c) 2003 Nokia. All rights reserved.
* ============================================================================
*/

// INCLUDE FILES


#include <Memento.rsg>
#include "Memento.hrh"
#include <eiklabel.h>	//for CEikLabel
#include <eikedwin.h>	//for CEikEdit
#include "LoginContainer.h"
#include <Aknnumseced.h>  //password
#include "MYSecrectEdwin.h"
#include "MementoAppUi.h"

#include <gulicon.h>
#include <aknutils.h>    // definition of AKN_LAF_COLOR()
#include <avkon.hrh>
#include <akntitle.h>
#include <aknnotewrappers.h>
#include <Aknnumseced.h> 
#include <barsread.h>
#include <W32STD.H>

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

// C++ default constructor can NOT contain any code, that
// might leave.
//
CLoginContainer::CLoginContainer()
    {
	m_pLabelName = NULL;
	m_pLabelPass = NULL;
	m_pLabelRePass = NULL;
	m_pEditName = NULL;
	m_pEditPass = NULL;
	m_pEditRePass = NULL;
    }

// EPOC default constructor can leave.
void CLoginContainer::ConstructL(const TRect& aRect)
    {
    CreateWindowL();


	//load chinese words//显示中文
	TBuf<32> chinese;
	CEikonEnv::Static()->ReadResource(chinese, R_QTN_MH_LONGIN_LABLE_NAME);


	//LabelName
	m_pLabelName = new(ELeave) CEikLabel;
	m_pLabelName->SetContainerWindowL(*this);
	m_pLabelName->SetTextL(chinese);
	m_pLabelName->SetExtent(TPoint(10,20), m_pLabelName->MinimumSize());

	//LabelPass
	CEikonEnv::Static()->ReadResource(chinese, R_QTN_MH_LONGIN_LABLE_PASSWORD);

	m_pLabelPass = new(ELeave) CEikLabel;
	m_pLabelPass->SetContainerWindowL(*this);
	m_pLabelPass->SetTextL(chinese);
	m_pLabelPass->SetExtent(TPoint(10,50), m_pLabelName->MinimumSize());

	//LabelRePass
	CEikonEnv::Static()->ReadResource(chinese, R_QTN_MH_LONGIN_LABLE_PASSWORDTWO);

	m_pLabelRePass = new(ELeave) CEikLabel;
	m_pLabelRePass->SetContainerWindowL(*this);
	m_pLabelRePass->SetTextL(chinese);
	m_pLabelRePass->SetExtent(TPoint(10,80), m_pLabelName->MinimumSize());


	//EditName
	m_pEditName = new(ELeave) CEikEdwin;
	m_pEditName->SetContainerWindowL(*this);
	m_pEditName->ConstructL(EAknEditorFlagDefault, 10, 10, 1);
	m_pEditName->SetAknEditorCurrentInputMode(EAknEditorTextInputMode);
	m_pEditName->SetExtent(TPoint(70,20), TSize(80,20));


	//EditPass
	m_pEditPass = new (ELeave) CMYSecrectEdwin();
	m_pEditPass->SetContainerWindowL(*this);
	m_pEditPass->SetInputCapabilitiesL(TCoeInputCapabilities::EWesternNumericIntegerPositive);
	m_pEditPass->ConstructL(EAknEditorFlagDefault, 10, 6, 1);
	m_pEditPass->SetExtent(TPoint(70,50), TSize(80,20));

	//EditRePass
	m_pEditRePass = new (ELeave) CMYSecrectEdwin();
	m_pEditRePass->SetContainerWindowL(*this);
	m_pEditRePass->SetInputCapabilitiesL(TCoeInputCapabilities::EWesternNumericIntegerPositive);
	m_pEditRePass->ConstructL(EAknEditorFlagDefault, 10, 6, 1);
	m_pEditRePass->SetExtent(TPoint(70,80), TSize(80,20));


	switch (iState)
	{
	case ELogin:
		{
		m_pLabelRePass->MakeVisible(EFalse);
		m_pEditRePass->MakeVisible(EFalse);
		TPtr ptr = ((CMementoAppUi*)iEikonEnv->AppUi())->GetDataManage()->GetName();
		TBuf16<11> name;
		name.Copy(ptr);
		m_pEditName->SetTextL(&name);
		m_pEditName->SetReadOnly(ETrue);
		m_pEditPass->SetFocus(ETrue);
		break;
		}
	case ERegister:
		{
		m_pEditName->SetTextL(&_L(""));
		m_pEditName->SetFocus(ETrue);
		m_pLabelRePass->MakeVisible(ETrue);
		m_pEditRePass->MakeVisible(ETrue);
		break;
		}
	default:
		break;
	}

    SetRect(aRect);
    ActivateL();
    }

// Destructor
CLoginContainer::~CLoginContainer()
    {
	MEM_FREE(m_pLabelName);
	MEM_FREE(m_pLabelPass);
	MEM_FREE(m_pLabelRePass);
	MEM_FREE(m_pEditName);
	MEM_FREE(m_pEditPass);
	MEM_FREE(m_pEditRePass);
    }

// ---------------------------------------------------------
// CLoginContainer::FocusTo(TInt aCommand)
// Change foccused control.
// (other items were commented in a header).
// ---------------------------------------------------------
//

void CLoginContainer::FocusTo(TInt aCommand)
    {
    }

// ---------------------------------------------------------
// CLoginContainer::SizeChanged()
// Called by framework when the view size is changed
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CLoginContainer::SizeChanged()
    {
    }

// ---------------------------------------------------------
// CLoginContainer::CountComponentControls() const
// (other items were commented in a header).
// ---------------------------------------------------------
//
TInt CLoginContainer::CountComponentControls() const
    {
		return 6; // return nbr of controls inside this container
    }

// ---------------------------------------------------------
// CLoginContainer::ComponentControl(TInt aIndex) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
CCoeControl* CLoginContainer::ComponentControl(TInt aIndex) const
    {
		switch (aIndex)
		{
		case 0:
			{
				return m_pLabelName;
				break;
			}
		case 1:
			{
				return m_pLabelPass;
				break;
			}
		case 2:
			{
				return m_pLabelRePass;
				break;
			}
		case 3:
			{
				return m_pEditRePass;
				break;
			}
		case 4:
			{
				return m_pEditPass;
				break;
			}
		case 5:
			{
				return m_pEditName;
				break;
			}
		default:
			{
				return NULL;
				break;
			}
		};
    }

// ---------------------------------------------------------
// CLoginContainer::Draw(const TRect& aRect) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CLoginContainer::Draw(const TRect& aRect) const
    {
    CWindowGc& gc = SystemGc();
    gc.SetPenStyle(CGraphicsContext::ENullPen);
    gc.SetBrushColor(KRgbGray);
    gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
    gc.DrawRect(aRect);
    }

// ---------------------------------------------------------
// CLoginContainer::OfferKeyEventL(...)
// Notify key events to editors.
// (other items were commented in a header).
// ---------------------------------------------------------
//
TKeyResponse CLoginContainer::OfferKeyEventL(
    const TKeyEvent& aKeyEvent, TEventCode aType)
	{
	if (m_pEditName)
	{
		if (m_pEditName->IsFocused())
		{
			if((aType == EEventKey) && (aKeyEvent.iCode == EKeyDownArrow))
			{
				m_pEditName->SetFocus(EFalse);
				m_pEditPass->SetFocus(ETrue);
				m_pEditRePass->SetFocus(EFalse);
				return EKeyWasConsumed;
			}
			return m_pEditName->OfferKeyEventL(aKeyEvent, aType);
		}
	}
	
	if (m_pEditPass)
	{
		if (m_pEditPass->IsFocused())
		{
			if((aType == EEventKey) && (aKeyEvent.iCode == EKeyUpArrow))
			{
				m_pEditName->SetFocus(ETrue);
				m_pEditPass->SetFocus(EFalse);
				m_pEditRePass->SetFocus(EFalse);
				return EKeyWasConsumed;
			}
			else if((aType == EEventKey) && (aKeyEvent.iCode == EKeyDownArrow) && (iState == ERegister))
			{
				m_pEditName->SetFocus(EFalse);
				m_pEditPass->SetFocus(EFalse);
				m_pEditRePass->SetFocus(ETrue);				
				return EKeyWasConsumed;
			}
			return m_pEditPass->OfferKeyEventL(aKeyEvent, aType);
		}
	}

	if (m_pEditRePass)
	{
		if (m_pEditRePass->IsFocused())
		{
			if((aType == EEventKey) && (aKeyEvent.iCode == EKeyUpArrow) && (iState == ERegister))
			{
				m_pEditName->SetFocus(EFalse);
				m_pEditPass->SetFocus(ETrue);
				m_pEditRePass->SetFocus(EFalse);
				return EKeyWasConsumed;
			}
			return m_pEditRePass->OfferKeyEventL(aKeyEvent, aType);
		}
	}
		return EKeyWasNotConsumed;
	}


// ---------------------------------------------------------
// CLoginContainer::HandleControlEventL(
//     CCoeControl* aControl,TCoeEvent aEventType)
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CLoginContainer::HandleControlEventL(
    CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
    {
    }

void CLoginContainer::setState(TInt aState)
{
	iState = aState;
}

void CLoginContainer::GetUserInfo(TDes& sUser,TDes& sPw1,TDes& sPw2)
{
	m_pEditName->GetText(sUser);
	m_pEditPass->GetText(sPw1);
	m_pEditRePass->GetText(sPw2);
}

// End of File  

⌨️ 快捷键说明

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