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

📄 mementoeditcontainer.cpp

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

// INCLUDE FILES
#include <Memento.rsg>
#include "Memento.hrh"
#include "MementoEditContainer.h"

#include <eiklabel.h>	//for CEikLabel
#include <eikedwin.h>	//for CEikEdit

#include "MementoAppUi.h" //for ReadResource()函数

// ================= MEMBER FUNCTIONS =======================
// C++ default constructor can NOT contain any code, that
// might leave.
//
CMementoEditContainer::CMementoEditContainer()
    {
	m_pLabel_1 = NULL;
	m_pEdit_1 = NULL;
	m_pEdit_2 = NULL;
    }

// EPOC default constructor can leave.
void CMementoEditContainer::ConstructL(const TRect& aRect)
    {
	TBuf<32> sName;
	CEikonEnv::Static()->ReadResource(sName, R_QTN_MH_EDIT_LABLE);//读入内存可在下面的show中显示——ReadResource()是个重要的函数。所有的中文都可以由它读到内存中再操作

    CreateWindowL();


	//Label_1
	m_pLabel_1 = new(ELeave) CEikLabel;
	m_pLabel_1->SetContainerWindowL(*this);
	m_pLabel_1->SetTextL(sName);
	m_pLabel_1->SetExtent(TPoint(5,5), m_pLabel_1->MinimumSize());

	//Edit_1
	m_pEdit_1 = new(ELeave) CEikEdwin;
	m_pEdit_1->SetContainerWindowL(*this);
	m_pEdit_1->ConstructL(EAknEditorFlagDefault, 15, 20, 1);
	m_pEdit_1->SetExtent(TPoint(42,4), TSize(127,18));
// 	m_pEdit_1->SetTextL(&_L("Input!"));
// 	m_pEdit_1->SetFocus(EFalse);

	//Edit_2
	m_pEdit_2 = new(ELeave) CEikEdwin;
	m_pEdit_2->SetContainerWindowL(*this);
	m_pEdit_2->ConstructL(EAknEditorFlagDefault, 30, 500, 6);
	m_pEdit_2->SetExtent(TPoint(7,35), TSize(163,95));
// 	m_pEdit_2->SetTextL(&_L("User!"));
// 	m_pEdit_2->SetFocus(EFalse);

    SetRect(aRect);
    ActivateL();
    }

// Destructor
CMementoEditContainer::~CMementoEditContainer()
    {
	MEM_FREE(m_pLabel_1);
	MEM_FREE(m_pEdit_1);
	MEM_FREE(m_pEdit_2);
    }

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

void CMementoEditContainer::FocusTo(TInt aCommand)
    {
    }

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

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

// ---------------------------------------------------------
// CMementoEditViewContainer::ComponentControl(TInt aIndex) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
CCoeControl* CMementoEditContainer::ComponentControl(TInt aIndex) const
{
	//return NULL;
	switch (aIndex)
	{
	case 0:
		{
			return m_pLabel_1;
			break;
		}
	case 1:
		{
			return m_pEdit_1;
			break;
		}
	case 2:
		{
			return m_pEdit_2;
			break;
		}
	default:
		{
			return NULL;
			break;
		}
	}	
}

// ---------------------------------------------------------
// CMementoEditViewContainer::Draw(const TRect& aRect) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CMementoEditContainer::Draw(const TRect& aRect) const
    {
	CWindowGc& gc = SystemGc();


    gc.SetBrushColor(KRgbWhite);
    gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
	gc.DrawRect(aRect);

	TSize PenSize2(3,3);//划线
	gc.SetPenSize(PenSize2);
    gc.SetPenStyle(CGraphicsContext::ESolidPen);
	gc.SetPenColor(KRgbBlue);

	gc.DrawLine(TPoint(0,27), TPoint(174,27));
	TSize PenSize(1,1);
	gc.SetPenSize(PenSize);
    gc.SetPenStyle(CGraphicsContext::ESolidPen);
	gc.SetPenColor(KRgbBlack);

	gc.DrawLine(TPoint(5,32), TPoint(170,32));//画边框
	gc.DrawLine(TPoint(5,137), TPoint(170,137));
	gc.DrawLine(TPoint(5,32), TPoint(5,137));
	gc.DrawLine(TPoint(170,137), TPoint(170,32));

	gc.DrawLine(TPoint(38,2), TPoint(170,2));//画边框
	gc.DrawLine(TPoint(38,22), TPoint(170,22));
	gc.DrawLine(TPoint(38,2), TPoint(38,22));
	gc.DrawLine(TPoint(170,22), TPoint(170,2));



	gc.SetPenColor(KRgbWhite);
	gc.SetPenStyle(CGraphicsContext::ENullPen);
	gc.SetBrushColor(KRgbWhite);
	gc.SetBrushStyle(CGraphicsContext::ENullBrush);
	
}

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


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

void CMementoEditContainer::SetStata(TState aFlag)
{
	iStata = aFlag;
}

CEikEdwin* CMementoEditContainer::GetTitleEdwin()
{
	return m_pEdit_1;
}

CEikEdwin* CMementoEditContainer::GetContentEdwin()
{
	return m_pEdit_2;
}

// TState CMementoEditViewContainer::GetStata(void)
// {
// 		return iStata;
// }
// End of File  

⌨️ 快捷键说明

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