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

📄 logincontainer.cpp

📁 symbian和旗下的HTTPENGINE的相关代码
💻 CPP
字号:
#include <AknsSkinInstance.h> //SKIN
#include <AknsUtils.h> //
#include <AknsDrawUtils.h> //
#include <gulicon.h>
#include <aknutils.h>
#include <avkon.hrh>
#include <akntitle.h>
#include <eiklabel.h>
#include <eikedwin.h>//CEikEdwin
#include <aknnumseced.h>//CAknNumericSecretEditor
#include <barsread.h>//TResourceReader
#include <gulbordr.h>

#include "ASSISTANT.rsg"
#include "LoginContainer.h"
#include "Common.h"

CLoginContainer::CLoginContainer()
{
	m_pLabelName = NULL;
	m_pLabelPassword = NULL;
	m_pPrePassword = NULL;
	m_pUsername = NULL;
	m_pPassword = NULL;
	m_pPrePassword = NULL;
	m_pBackGround = NULL;
	m_nKeyFlag = -1;
}

// EPOC default constructor can leave.
void CLoginContainer::ConstructL(const TRect& aRect)
{
    CreateWindowL();
//用户名
	m_pLabelName = new (ELeave) CEikLabel;
    m_pLabelName->SetContainerWindowL( *this );
    TBuf<32> buf;
	CEikonEnv::Static()->ReadResource(buf, R_ASS_TAS_USERNAME);
    m_pLabelName->SetTextL(buf);
	m_pLabelName->SetExtent( TPoint(10,12), m_pLabelName->MinimumSize() );	
	
//密码
	m_pLabelPassword = new (ELeave) CEikLabel;
    m_pLabelPassword->SetContainerWindowL( *this );
	CEikonEnv::Static()->ReadResource(buf, R_ASS_TAS_PASSWORD);
    m_pLabelPassword->SetTextL(buf);
	m_pLabelPassword->SetExtent( TPoint(10,52), m_pLabelPassword->MinimumSize() );

//prepassword label
	m_pLabelPrePassword = new (ELeave) CEikLabel;
	m_pLabelPrePassword->SetContainerWindowL( *this );
	CEikonEnv::Static()->ReadResource(buf, R_ASS_TAS_PREPASSWORD);
	m_pLabelPrePassword->SetTextL(buf);
	m_pLabelPrePassword->SetExtent( TPoint(10,92), m_pLabelPrePassword->MinimumSize() );
	m_pLabelPrePassword->MakeVisible(EFalse);

//edit
	m_pUsername = new (ELeave) CEikEdwin(TGulBorder::ESingleBlack);
 	m_pUsername->SetContainerWindowL(*this);
 	m_pUsername->ConstructL(EEikEdwinNoAutoSelection | EEikEdwinIgnoreVirtualCursor , 11, 11, 1);
	m_pUsername->SetAknEditorCurrentInputMode(EAknEditorNumericInputMode);
	m_pUsername->SetAknEditorAllowedInputModes(EAknEditorNumericInputMode);  //只能输入数字
	m_pUsername->SetAknEditorFlags(EAknEditorFlagLatinInputModesOnly);		//
	m_pUsername->SetExtent(TPoint(60,10),TSize(100,20));
	m_pUsername->SetFocus(ETrue);
	
//password Edit	
	TResourceReader reader;
	iCoeEnv->CreateResourceReaderLC(reader, R_PASSWORD_STAR_BUF);
	m_pPassword = new (ELeave) CAknNumericSecretEditor;
	m_pPassword->SetContainerWindowL(*this);
	m_pPassword->ConstructFromResourceL(reader);
	CleanupStack::PopAndDestroy();
	m_pPassword->SetExtent(TPoint(60, 50), TSize(100, 20));
	m_pPassword->SetFocus(EFalse);

//prepassword edit
	TResourceReader reader1;
	iCoeEnv->CreateResourceReaderLC(reader1, R_PASSWORD_STAR_BUF);
	m_pPrePassword = new (ELeave) CAknNumericSecretEditor;
	m_pPrePassword->SetContainerWindowL(*this);
	m_pPrePassword->ConstructFromResourceL(reader1);
	CleanupStack::PopAndDestroy();
	m_pPrePassword->SetExtent(TPoint(60, 90), TSize(100, 20));
	m_pPrePassword->SetFocus(EFalse);
	m_pPrePassword->MakeVisible(EFalse);

    SetRect( aRect );
	m_pBackGround = CAknsBasicBackgroundControlContext::NewL( KAknsIIDQsnBgAreaMain,aRect,ETrue);//skin
    ActivateL();
}

// destructor
CLoginContainer::~CLoginContainer()
{
	MEMORY_FREE(m_pUsername);
	MEMORY_FREE(m_pPassword);
	MEMORY_FREE(m_pLabelName);
	MEMORY_FREE(m_pLabelPassword);
	MEMORY_FREE(m_pPrePassword);
	MEMORY_FREE(m_pLabelPrePassword);
	MEMORY_FREE(m_pBackGround);	
}

void CLoginContainer::SizeChanged()
{
}

// ---------------------------------------------------------
// CLoginContainer::CountComponentControls() const
// return the number of controls
// ---------------------------------------------------------
//
TInt CLoginContainer::CountComponentControls() const
{
	// return number of controls inside this container
	return 6; 
}

// ---------------------------------------------------------
// CLoginContainer::ComponentControl(TInt aIndex) const
// return the pointer to specified control.
// ---------------------------------------------------------
//
CCoeControl* CLoginContainer::ComponentControl( TInt aIndex ) const
{
	switch(aIndex) 
	{
	case 0:
		return m_pUsername;
		break;
	case 1:
		return m_pPassword;
		break;
	case 2:
		return m_pLabelName;
		break;
	case 3:
		return m_pLabelPassword;
		break;
	case 4:
		return m_pPrePassword;
		break;
	case 5:
		return m_pLabelPrePassword;
		break;
	default:
		return NULL;
		break;
	}
}

// ---------------------------------------------------------
// CLoginContainer::Draw(const TRect& aRect) const
// handle the message when client region must be redrawn.
// ---------------------------------------------------------
//
void CLoginContainer::Draw( const TRect& aRect ) const
{
	CWindowGc& gc = SystemGc();
	MAknsSkinInstance* skin = AknsUtils::SkinInstance();
	MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
    AknsDrawUtils::Background( skin, cc, this, gc, aRect );

//	gc.Clear(Rect());
	gc.DrawRect(TRect(TPoint(59,9),TSize(102,22)));
	gc.DrawRect(TRect(TPoint(59,49),TSize(102,24)));
	if (m_nKeyFlag == 0 )
	{
		gc.DrawRect(TRect(TPoint(59,89),TSize(102,24)));
	}
	
}

// ---------------------------------------------------------
// CAknExGridContainer::OfferKeyEventL(
//           const TKeyEvent& aKeyEvent, TEventCode aType )
// Handles the key events.
// ---------------------------------------------------------
//
TKeyResponse CLoginContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType )
{
//	if (aKeyEvent.iScanCode == 167) {
//		iView->HandleCommandL();
// 	}									//ok

	if (m_pUsername)
	{				
		if (m_pUsername->IsFocused())
		{
			if((aType == EEventKey) && (aKeyEvent.iCode == EKeyDownArrow))
			{
				m_pUsername->SetFocus(EFalse);
				m_pPassword->SetFocus(ETrue);
				return EKeyWasConsumed;
			}
			return m_pUsername->OfferKeyEventL(aKeyEvent, aType);
		}
	}

	if (m_pPassword)
	{
		if (m_pPassword->IsFocused())
		{
			if((aType == EEventKey) && (aKeyEvent.iCode == EKeyUpArrow))
			{
				m_pPassword->SetFocus(EFalse);
				m_pUsername->SetFocus(ETrue);
				return EKeyWasConsumed;	
			}
			
			if (m_nKeyFlag == 0) 
			{
				if ((aType == EEventKey) && (aKeyEvent.iCode == EKeyDownArrow))
				{
					m_pPassword->SetFocus(EFalse);
					m_pPrePassword->SetFocus(ETrue);
					return EKeyWasConsumed;
				}
			}
			return m_pPassword->OfferKeyEventL(aKeyEvent, aType);
		}		
	}
	if (m_nKeyFlag == 0 ) {
		if (m_pPrePassword)
		{
			if (m_pPrePassword->IsFocused())
			{
				if((aType == EEventKey) && (aKeyEvent.iCode == EKeyUpArrow))
				{
					m_pPrePassword->SetFocus(EFalse);
					m_pPassword->SetFocus(ETrue);
					return EKeyWasConsumed;
				}
				return m_pPrePassword->OfferKeyEventL(aKeyEvent, aType);
			}
		}		
	return EKeyWasNotConsumed;
	}
	else
		return EKeyWasNotConsumed;

}

void CLoginContainer::SetPreVisible()
{
	m_nKeyFlag = 0;
	m_pLabelPrePassword->MakeVisible(ETrue);
	m_pPrePassword->MakeVisible(ETrue);
	m_pUsername->SetFocus(ETrue);
}
void CLoginContainer::SetPreUnVisible()
{
	m_nKeyFlag = -1;
	m_pLabelPrePassword->MakeVisible(EFalse);
	m_pPrePassword->MakeVisible(EFalse);
	m_pUsername->SetFocus(ETrue);
}

void CLoginContainer::GetUserName(TDes& aUserName)
{
	m_pUsername->GetText(aUserName);
}
void CLoginContainer::GetPassword(TDes& aPassword)
{
	m_pPassword->GetText(aPassword);
}
void CLoginContainer::GetPrePassword(TDes& aPrePassword)
{
	m_pPrePassword->GetText(aPrePassword);
}
// End of File  

TTypeUid::Ptr CLoginContainer::MopSupplyObject(TTypeUid aId)//主题
{
	if (m_pBackGround )
	{
		return MAknsControlContext::SupplyMopObject( aId, m_pBackGround );
	}
	return CCoeControl::MopSupplyObject(aId);
}

⌨️ 快捷键说明

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