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

📄 registercontainer.cpp.bak

📁 个人手机助理套件:包含1、记事本(备忘录)、名片夹、名片夹的上传下载(异地备份)、短消息模块
💻 BAK
字号:
/*
* ============================================================================
*  Name     : CRegisterContainer from CCoeControl, MCoeControlObserver
*  Part of  : Register
*  Copyright (c) 2003 Nokia. All rights reserved.
* ============================================================================
*/

// INCLUDE FILES
#include <HelperGenius.rsg>
#include "HelperGenius.hrh"
#include "RegisterContainer.h"

#include <eiklabel.h>
#include <eikedwin.h>
#include <eikenv.h>
#include <fbs.h>
#include <AknUtils.h>
#include <Helpergenius.mbg>
#include <barsread.h>
#include <AknNumSecEd.h>
// ================= MEMBER FUNCTIONS =======================

// C++ default constructor can NOT contain any code, that
// might leave.
//

#define  DELPTR(p) if(p!=NULL){ delete p;p=NULL;}

CRegisterContainer::CRegisterContainer()
    {
    m_plabelName = NULL;
	m_plabelPassword = NULL;
	m_plabelVPassword = NULL;
	m_peditName = NULL;
	m_peditPassword = NULL;
	   m_pBitmap = NULL;

	m_peditVPassword = NULL;
    }

// EPOC default constructor can leave.
void CRegisterContainer::ConstructL(const TRect& aRect)
    {
    CreateWindowL();
	m_pBitmap = new (ELeave) CFbsBitmap;
	TBuf<KMaxPath> pathMbm;
#ifdef __WINS__
	pathMbm.Copy(_L("z:\\system\\apps\\HelperGenius\\HelperGenius.mbm"));
#else
	CHelperGeniusAppUi* pApp = (CHelperGeniusAppUi*)CEikonEnv::Static()->AppUi();
	pApp->GetAppPath(pathMbm);
	
	pathMbm.Append(_L("HelperGenius.mbm"));
#endif
    User::LeaveIfError(CompleteWithAppPath(pathMbm));
    User::LeaveIfError(m_pBitmap->Load(pathMbm,EMbmHelpergeniusHelpergenius_icon_17));
    /*******设置标签***********************************************
     ***********姓名标签**************************************************************/
    m_plabelName = new (ELeave) CEikLabel;
    CleanupStack::PushL(m_plabelName);
    m_plabelName->SetContainerWindowL(*this);
    
    TBuf<32> sTmplabelName;
    CEikonEnv::Static()->ReadResource(sTmplabelName,R_QTN_MH_REGISTER_USERNAME);
    m_plabelName->SetTextL(sTmplabelName);
    m_plabelName->SetExtent(TPoint(10,20),m_plabelName->MinimumSize( ) );
    CleanupStack::Pop( m_plabelName );
    /****************密码标签***********************************************************/
    m_plabelPassword = new (ELeave) CEikLabel;
    CleanupStack::PushL(m_plabelPassword);
    m_plabelPassword->SetContainerWindowL(*this);
    
    TBuf<32> sTmplabelPass;
    CEikonEnv::Static()->ReadResource(sTmplabelPass,R_QTN_MH_REGISTER_USERPASS);
    m_plabelPassword->SetTextL(sTmplabelPass);
    m_plabelPassword->SetExtent(TPoint(10,60),m_plabelPassword->MinimumSize( ) );
    CleanupStack::Pop( m_plabelPassword );
    /*****************确认密码标签***************************************************/
    m_plabelVPassword = new (ELeave) CEikLabel;
    CleanupStack::PushL(m_plabelVPassword);
    m_plabelVPassword->SetContainerWindowL(*this);
    
    TBuf<32> sTmplabelword;
    CEikonEnv::Static()->ReadResource(sTmplabelword,R_QTN_MH_REGISTER_USERPASSSEC);
    m_plabelVPassword->SetTextL(sTmplabelword);
    m_plabelVPassword->SetExtent(TPoint(10,100),m_plabelVPassword->MinimumSize( ) );
    CleanupStack::Pop( m_plabelVPassword );
    /****************设置编辑框***********************************************************
      ***************姓名编辑框**********************************************************/
    TResourceReader reader1;
    iCoeEnv->CreateResourceReaderLC(reader1,R_AKNEXEDITOR_ONE_EDWIN);
    m_peditName = new(ELeave) CEikEdwin;
    m_peditName->SetContainerWindowL(*this);
    m_peditName->ConstructFromResourceL(reader1);
    CleanupStack::PopAndDestroy( );
    m_peditName->SetExtent(TPoint(90,20),TSize(80,20));
 //   m_peditName->SetTextL(&_L(""));
    m_peditName->SetFocus(ETrue);
    /****************密码编辑框************************************************************/ 

	m_peditPassword = new(ELeave) CAknNumericSecretEditor; 
	m_peditPassword->SetContainerWindowL(*this);
	TResourceReader reader2;
	CEikonEnv::Static()->CreateResourceReaderLC(reader2,R_MY_SECRETED); 
	m_peditPassword->ConstructFromResourceL(reader2);
	CleanupStack::PopAndDestroy();
	m_peditPassword->SetExtent(TPoint(90,60),TSize(80,20));
	m_peditPassword->SetFocus(EFalse);
    /*****************确认密码编辑框*******************************************************/
    TResourceReader reader3;
    iCoeEnv->CreateResourceReaderLC(reader3,R_MY_SECRETED);
    m_peditVPassword = new(ELeave) CAknNumericSecretEditor;
    m_peditVPassword->SetContainerWindowL(*this);
    m_peditVPassword->ConstructFromResourceL(reader3);
    CleanupStack::PopAndDestroy( );
    m_peditVPassword->SetExtent(TPoint(90,100),TSize(80,20));
	
    m_peditVPassword->SetFocus(EFalse);
    SetRect(aRect);
    ActivateL();
    }

// Destructor
CRegisterContainer::~CRegisterContainer()
    {
    DELPTR(m_plabelName);
	DELPTR(m_plabelPassword);
	DELPTR(m_plabelVPassword);
	DELPTR(m_peditName);
	DELPTR(m_peditPassword);
	  DELPTR(m_pBitmap);

	DELPTR(m_peditVPassword);
    }

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

void CRegisterContainer::FocusTo(TInt aCommand)
    {
    }

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

// ---------------------------------------------------------
// CRegisterContainer::CountComponentControls() const
// (other items were commented in a header).
// ---------------------------------------------------------
//
TInt CRegisterContainer::CountComponentControls() const
    {
    return 6; 
    }

// ---------------------------------------------------------
// CRegisterContainer::ComponentControl(TInt aIndex) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
CCoeControl* CRegisterContainer::ComponentControl(TInt aIndex) const
    {
	switch(aIndex)
	{
	case 0:
		{
			return m_plabelName;
			break;
		}
	case 1:
		{
			return m_peditName;
			break;
		}
	case 2:
		{
			return m_plabelPassword;
			break;
		}
	case 3:
		{
			return m_peditPassword;
			break;
		}
	case 4:
		{
			return m_plabelVPassword;
			break;
		}
	case 5:
		{
			return m_peditVPassword;
			break;
		}
	default:
		{
			return NULL;
            break;
		}
	}	
    }

// ---------------------------------------------------------
// CRegisterContainer::Draw(const TRect& aRect) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CRegisterContainer::Draw(const TRect& aRect) const
    {
    CWindowGc& gc = SystemGc();
	/******添加背景图片*******************************************/
    gc.Clear(aRect);
    TPoint topLeft(0,0);
	//    gc.DrawBitmap(TRect(topLeft,TSize(176,208)),m_pBitmap);
    gc.BitBlt(topLeft,m_pBitmap,TRect(topLeft,TSize(176,208)));
    }

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

	if (m_peditVPassword)
	{
		if (m_peditVPassword->IsFocused())
		{
			if((aType == EEventKey) && (aKeyEvent.iCode == EKeyDownArrow))
			{
				m_peditName->SetFocus(EFalse);
				m_peditPassword->SetFocus(EFalse);
				m_peditVPassword->SetFocus(ETrue);
				return EKeyWasConsumed;
			}
			else if((aType == EEventKey) && (aKeyEvent.iCode == EKeyUpArrow))
			{
				m_peditName->SetFocus(EFalse);
				m_peditPassword->SetFocus(ETrue);
				m_peditVPassword->SetFocus(EFalse);
				return EKeyWasConsumed;
			}
			return m_peditVPassword->OfferKeyEventL(aKeyEvent, aType);
		}
	}

    return EKeyWasNotConsumed;
    }


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

void	CRegisterContainer::GetName( TDes &aName )
{
	m_peditName->GetText(aName);
}

void	CRegisterContainer::GetPassword( TDes &aPassword )
{
	m_peditPassword->GetText(aPassword);
}

void	CRegisterContainer::GetVPassword( TDes &aVPassword )
{
	m_peditVPassword->GetText(aVPassword);
}

// End of File  

⌨️ 快捷键说明

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