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

📄 meginfocontainer.cpp

📁 symbian系统上的记事本程序
💻 CPP
字号:
/*
* ============================================================================
*  Name     : CMegInfoContainer from CCoeControl, MCoeControlObserver
*  Part of  : Hello
*  Copyright (c) 2003 Nokia. All rights reserved.
* ============================================================================
*/

// INCLUDE FILES


#include <EveryDay.rsg>
#include "EveryDay.hrh"
#include "MegInfoContainer.h"

#include <eiklabel.h>
#include <eikedwin.h>
#include "common.h"
// ================= MEMBER FUNCTIONS =======================

// C++ default constructor can NOT contain any code, that
// might leave.
//
CMegInfoContainer::CMegInfoContainer()
{
	m_pLabel = NULL;
	m_pLabel1 = NULL;
	m_pEdit = NULL;
	m_pEdit1 = NULL;
}

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

	//Label for telephone
	m_pLabel = new(ELeave) CEikLabel;
	m_pLabel->SetContainerWindowL(*this);
	m_pLabel->SetTextL(_L("phone :"));
	m_pLabel->SetExtent(TPoint(10,20), m_pLabel->MinimumSize());
	
	m_pLabel1 = new(ELeave) CEikLabel;
	m_pLabel1->SetContainerWindowL(*this);
	m_pLabel1->SetTextL(_L("Massege"));
	m_pLabel1->SetExtent(TPoint(10,50), m_pLabel->MinimumSize());
	
	//Edit
	m_pEdit = new(ELeave) CEikEdwin;
	m_pEdit->SetContainerWindowL(*this);
	m_pEdit->ConstructL(EAknEditorFlagDefault, 10, 11, 1);
	m_pEdit->SetExtent(TPoint(60,20), TSize(80,20));
/*	m_pEdit->SetTextL(&_L("1234"));*/
	m_pEdit->SetFocus(ETrue);
	m_pEdit->SetAknEditorCurrentInputMode(EAknEditorNumericInputMode);//only Input number.
	
	m_pEdit1 = new(ELeave) CEikEdwin;
	m_pEdit1->SetContainerWindowL(*this);
	m_pEdit1->ConstructL(EAknEditorFlagDefault, 10, 70, 1);
	m_pEdit1->SetExtent(TPoint(60,50), TSize(80,80));
/*	m_pEdit1->SetTextL(&_L("NULL"));*/
	m_pEdit1->SetFocus(EFalse);
	
    SetRect(aRect);
    ActivateL();
}

// Destructor
CMegInfoContainer::~CMegInfoContainer()
{
	MEM_FREE(m_pLabel);
	MEM_FREE(m_pEdit);
	MEM_FREE(m_pLabel1);
	MEM_FREE(m_pEdit1);
}

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

void CMegInfoContainer::FocusTo(TInt aCommand)
{
}

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

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

// ---------------------------------------------------------
// CMegInfoContainer::ComponentControl(TInt aIndex) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
CCoeControl* CMegInfoContainer::ComponentControl(TInt aIndex) const
{
	//return NULL;
	switch (aIndex)
	{
	case 0:
		{
			return m_pLabel;
			break;
		}
	case 1:
		{
			return m_pLabel1;
			break;
		}
	case 2:
		{
			return m_pEdit;
			break;
		}
	case 3:
		{
			return m_pEdit1;
			break;
		}
	default:
		{
			return NULL;
			break;
		}
	}
}

// ---------------------------------------------------------
// CMegInfoContainer::Draw(const TRect& aRect) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CMegInfoContainer::Draw(const TRect& aRect) const
{
    CWindowGc& gc = SystemGc();
    gc.SetPenStyle(CGraphicsContext::ENullPen);
    gc.SetBrushColor(KRgbGreen);
    gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
    gc.DrawRect(aRect);
	gc.SetPenStyle(CGraphicsContext::ESolidPen);
	gc.SetPenColor(KRgbBlack);
	
	TRect rect;
	rect.iTl = TPoint(58,18);
	rect.iBr = TPoint(142,42);
	gc.DrawRect(rect);
	
	rect.iTl = TPoint(58,48);
	rect.iBr = TPoint(142,132);
	gc.DrawRect(rect);	
}

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


// ---------------------------------------------------------
// CMegInfoContainer::HandleControlEventL(
//     CCoeControl* aControl,TCoeEvent aEventType)
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CMegInfoContainer::HandleControlEventL(
										  CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
{
}
void CMegInfoContainer::GetAddress(TDes& aAddress, TDes& aMessege)
{
	m_pEdit->GetText(aAddress);
	m_pEdit1->GetText(aMessege);
}

void CMegInfoContainer::SetEditReadOnly()
{
	m_pEdit->SetReadOnly(ETrue);
	m_pEdit1->SetReadOnly(ETrue);
} 
void CMegInfoContainer::SetInfo(TDes& aAddress, TDes& aMessege)
{
	m_pEdit->SetTextL(&aAddress);
	m_pEdit1->SetTextL(&aMessege);
}
// End of File  

⌨️ 快捷键说明

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