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

📄 modtxtcontainer.cpp.bak

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

// INCLUDE FILES


#include <EveryDay.rsg>
#include "EveryDay.hrh"
#include "ModTxtContainer.h"
#include "Common.h"
#include <eiklabel.h>
#include <eikedwin.h>
#include <aknnotewrappers.h> 
#include "Message.h"
#include "File.h"
#include "SendTxt.h"

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

// C++ default constructor can NOT contain any code, that
// might leave.
//
CModTxtContainer::CModTxtContainer()
{
	m_pModLabel = NULL;
	m_pModLabel1 = NULL;
	m_pModEdit = NULL;
	m_pModEdit1 = NULL;

}

// EPOC default constructor can leave.
void CModTxtContainer::ConstructL(const TRect& aRect)
{
    CreateWindowL();
	//Label
	m_pModLabel = new(ELeave) CEikLabel;
	m_pModLabel->SetContainerWindowL(*this);
	TBuf<32> buf;
	CEikonEnv::Static()->ReadResource(buf, R_QTN_MODTXT_NEXTITLE);
	m_pModLabel->SetTextL(buf); 
	m_pModLabel->SetExtent(TPoint(10,20), m_pModLabel->MinimumSize());
	
	//Label1
	m_pModLabel1 = new(ELeave) CEikLabel;
	m_pModLabel1->SetContainerWindowL(*this);
	CEikonEnv::Static()->ReadResource(buf, R_QTN_MODTXT_CONTENT);
	m_pModLabel1->SetTextL(buf); 
	m_pModLabel1->SetExtent(TPoint(10,50), m_pModLabel1->MinimumSize());
	
	//Edit
	m_pModEdit = new(ELeave) CEikEdwin;
	m_pModEdit->SetContainerWindowL(*this);
	m_pModEdit->ConstructL(EAknEditorFlagDefault, 10, 10, 1);
	m_pModEdit->SetExtent(TPoint(55,20), TSize(80,20));
	m_pModEdit->SetTextL(&_L("Input Title!"));
	m_pModEdit->SetFocus(ETrue);
	
	//Edit1
	m_pModEdit1 = new(ELeave) CEikEdwin;
	m_pModEdit1->SetContainerWindowL(*this);
	m_pModEdit1->ConstructL(EAknEditorFlagDefault, 10, 100, 1);
	m_pModEdit1->SetExtent(TPoint(40,50), TSize(120,80));
	m_pModEdit1->SetTextL(&_L("Input content!"));
    SetRect(aRect);
    ActivateL();
}

// Destructor
CModTxtContainer::~CModTxtContainer()
{
	MEM_FREE(m_pModLabel);
	MEM_FREE(m_pModLabel1);
	MEM_FREE(m_pModEdit);
	MEM_FREE(m_pModEdit1);
	MEM_FREE(m_Modmessage);
}

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

void CModTxtContainer::FocusTo(TInt aCommand)
{
}

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

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

// ---------------------------------------------------------
// CModTxtContainer::ComponentControl(TInt aIndex) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
CCoeControl* CModTxtContainer::ComponentControl(TInt aIndex) const
{
	switch (aIndex)
	{
	case 0:
		{
			return m_pModLabel;
			break;
		}
	case 1:
		{
			return m_pModLabel1;
			break;
		}
	case 2:
		{
			return m_pModEdit;
			break;
		}
	case 3:
		{
			return m_pModEdit1;
			break;
		}
	default:
		{
			return NULL;
			break;
		}
	}
}

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

	gc.SetPenStyle(CGraphicsContext::ESolidPen);
	gc.SetPenColor(KRgbBlack);
	gc.DrawLine(TPoint (53,18),TPoint (150,18));
	gc.DrawLine(TPoint (53,18),TPoint (53,40));
	gc.DrawLine(TPoint (53,40),TPoint (150,40));
	gc.DrawLine(TPoint (150,18),TPoint (150,40));
	
	gc.DrawLine(TPoint (38,48),TPoint (162,48));
	gc.DrawLine(TPoint (38,48),TPoint (38,132));
	gc.DrawLine(TPoint (38,132),TPoint (162,132));
	gc.DrawLine(TPoint (162,48),TPoint (162,132));
}

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


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

void CModTxtContainer::LIstInfo(CMessage& afile)
{
	m_Modmessage->iFileTitle.Copy(afile.iFileTitle);
	m_Modmessage->iFileContent.Copy(afile.iFileContent);		
	
}

TInt CNewTxtContainer::GetTitle()
{
	TBuf<32> title;
	m_pNewEdit->GetText(title);
	TInt num = title.Length();
	return num;
}

void CNewTxtContainer::GetTitle(TDes& title)
{
	m_pNewEdit->GetText(title);
}
void CNewTxtContainer::GetContext(TDes& context)
{
	m_pNewEdit1->GetText(context);
}
// End of File  

⌨️ 快捷键说明

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