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

📄 registcontainer.cpp

📁 symbian控件的利用
💻 CPP
字号:
/*
* ============================================================================
*  Name     : CRegistContainer from CCoeControl, MCoeControlObserver
*  Part of  : Regist
*  Copyright (c) 2003 Nokia. All rights reserved.
* ============================================================================
*/

// INCLUDE FILES
#include <eiklabel.h>		// for example label control
#include <barsread.h>		// for resource reader
#include <eikedwin.h>		// for CEikEdwin
#include <eikgted.h>		// for CEikGlobalTextEditor
#include <eikseced.h>       // for secret editor
#include <AknNumSecEd.h>    // for numeric secret editor

#include <LDMCM8.rsg>
#include "LDMCM8.hrh"
#include "RegistContainer.h"

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

// C++ default constructor can NOT contain any code, that
// might leave.
//
CRegistContainer::CRegistContainer()
:iLabelName(NULL), iEdwinName(NULL),iLabelPWD1(NULL),iEdwinPWD1(NULL),iLabelPWD2(NULL),iEdwinPWD2(NULL)
{
}

// EPOC default constructor can leave.
void CRegistContainer::ConstructL(const TRect& aRect)
{
    CreateWindowL();
	
    TBuf<50> text1;	
    iCoeEnv->ReadResource(text1, R_QTN_MCM_CLIENTNAME);
    iLabelName = new (ELeave) CEikLabel;
    iLabelName->SetContainerWindowL(*this);
    iLabelName->SetTextL(text1);
    iLabelName->SetExtent(TPoint(20, 30), iLabelName->MinimumSize());
	
	iEdwinName = new (ELeave) CEikEdwin(/*TGulBorder::ESingleBlack*/);
	iEdwinName->SetContainerWindowL(*this);
	iEdwinName->ConstructL(EEikEdwinNoAutoSelection | EEikEdwinIgnoreVirtualCursor, 10, 10, 1);
	iEdwinName->SetExtent(TPoint(80, 25), TSize(70, 20));

    TBuf<50> text2;
    iCoeEnv->ReadResource(text2, R_QTN_MCM_CLIENTPWD);
    iLabelPWD1 = new (ELeave) CEikLabel;
    iLabelPWD1->SetContainerWindowL(*this);
    iLabelPWD1->SetTextL(text2);
    iLabelPWD1->SetExtent(TPoint(20, 60), iLabelPWD1->MinimumSize());

	/******************************************
	 *
	 * NumericSecretEditor for pwd input 
	 * @ 2008-5-23 10:38 by Miserce
	 * @ ex from editor container23
	 *
	 ******************************************/
    TResourceReader reader1;
    iCoeEnv->CreateResourceReaderLC(reader1,
                                     R_QTN_MCM_NUMSECTET_COUNT);
    iEdwinPWD1 = new (ELeave) CAknNumericSecretEditor();
    iEdwinPWD1->SetContainerWindowL(*this);
    iEdwinPWD1->ConstructFromResourceL(reader1);
    CleanupStack::PopAndDestroy();  // Resource reader
    iEdwinPWD1->SetExtent(TPoint(80, 55), TSize(70, 20));

    TBuf<50> text3;
    iCoeEnv->ReadResource(text3, R_QTN_MCM_REGIST_CLIENTPWD);
    iLabelPWD2 = new (ELeave) CEikLabel;
    iLabelPWD2->SetContainerWindowL(*this);
    iLabelPWD2->SetTextL(text3);
    iLabelPWD2->SetExtent(TPoint(20, 90), iLabelPWD2->MinimumSize());

    TResourceReader reader2;
    iCoeEnv->CreateResourceReaderLC(reader2,
                                     R_QTN_MCM_NUMSECTET_COUNT);
    iEdwinPWD2 = new (ELeave) CAknNumericSecretEditor();
    iEdwinPWD2->SetContainerWindowL(*this);
    iEdwinPWD2->ConstructFromResourceL(reader2);
    CleanupStack::PopAndDestroy();  // Resource reader
    iEdwinPWD2->SetExtent(TPoint(80, 85), TSize(70, 20));

	iEdwinName->SetFocus(ETrue);

    SetRect(aRect);
    ActivateL();
}

// Destructor
CRegistContainer::~CRegistContainer()
{
	if (iLabelName!=NULL)
	{
		delete iLabelName;
	}
	if (iEdwinName!=NULL)
	{
		delete iEdwinName;
	}
	if (iLabelPWD1!=NULL)
	{
		delete iLabelPWD1;
	}
	if (iEdwinPWD1!=NULL)
	{
		delete iEdwinPWD1;
	}
	if (iLabelPWD2!=NULL)
	{
		delete iLabelPWD2;
	}
	if (iEdwinPWD2!=NULL)
	{
		delete iEdwinPWD2;
	}
}

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

void CRegistContainer::FocusTo(TInt aCommand)
{
	//     switch(aCommand)
	//         {
	//         case ERegistCmdSelectEdwin1:
	//             iGTextEd->SetFocus(EFalse);
	//             iEdwin->SetFocus(ETrue);
	//             break;
	//         case ERegistCmdSelectGTextEd1:
	//             iEdwin->SetFocus(EFalse);
	//             iGTextEd->SetFocus(ETrue);
	//             break;
	//         default:
	//             break;
	//         }
}

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

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

// ---------------------------------------------------------
// CRegistContainer::ComponentControl(TInt aIndex) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
CCoeControl* CRegistContainer::ComponentControl(TInt aIndex) const
{
	switch (aIndex)
	{
	case 0:
		return iLabelName;
 	case 1:
 		return iEdwinName;
 	case 2:
 		return iLabelPWD1;
 	case 3:
 		return iEdwinPWD1;
 	case 4:
 		return iLabelPWD2;
 	case 5:
 		return iEdwinPWD2;
	default:
		return NULL;
	}
}

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

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

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

			return iEdwinPWD1->OfferKeyEventL(aKeyEvent, aType);
		}
	}
	if (iEdwinPWD2)
	{
		if (iEdwinPWD2->IsFocused())
		{
			if ((aType == EEventKey) && (aKeyEvent.iCode == EKeyUpArrow))
			{
				iEdwinPWD2->SetFocus(EFalse);
				iEdwinPWD1->SetFocus(ETrue);
				return EKeyWasConsumed;
			}
			return iEdwinPWD2->OfferKeyEventL(aKeyEvent, aType);
		}
	}
	//     if (iEdwin)
	//         {
	//         if (iEdwin->IsFocused())
	//             {
	//             return iEdwin->OfferKeyEventL(aKeyEvent, aType);
	//             }
	//         }
	//     if (iGTextEd)
	//         {
	//         if (iGTextEd->IsFocused())
	//             {
	//             return iGTextEd->OfferKeyEventL(aKeyEvent, aType);
	//             }
	//         }
    //return EKeyWasNotConsumed;
}

/*******************************
 * get editor info
 *******************************/
void CRegistContainer::GetInput (TDes& aBuf, TInt aType)
{
	switch(aType)
	{
	case 1://name
		iEdwinName->GetText(aBuf);
		break;
	case 2:
		iEdwinPWD1->GetText(aBuf);
	    break;
	case 3:
		iEdwinPWD2->GetText(aBuf);
		break;
	}
}



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

// End of File  

⌨️ 快捷键说明

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