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

📄 chsgopentextcontainer.cpp

📁 Symbian工程 九宫格界面
💻 CPP
字号:
#include <gulicon.h>
#include <aknutils.h>
#include <avkon.hrh>

#include "CHsgOpenTextContainer.h"
#include "LxdMessageManagement.h"
#include "CHsgOpenTextView.h"
#include "CJGProjectappui.h"
#include <eiklabel.h>
#include "CJGProject.rsg"
#include <eikedwin.h>
#include <BARSREAD.H>
#include "NewsRollText.h"
#include "HsgTextView.h"
#include "LxdAD.h"
#include "CJGProject.rsg"
#define MEMORY_FREE(a) if(a){delete a; a=NULL;}


CHsgOpenTextContainer::CHsgOpenTextContainer()
{
	iHsgLableOpenTitle        =NULL;
	iHsgLableOpenContent      =NULL;

	iHsgEditorOpenTitle       =NULL;
	iHsgEditorOpenContent     =NULL;
	iOpenMesLabel             =NULL;
	iLxdOpenPointer           =NULL;
}

// EPOC default constructor can leave.
void CHsgOpenTextContainer::ConstructL(const TRect& aRect)
{
    CreateWindowL();	
    SetRect( aRect );
    SetExtentToWholeScreen();
	//动态创建标题Label

	iHsgLableOpenTitle = new(ELeave) CEikLabel;		
	iHsgLableOpenTitle->SetContainerWindowL(*this);
	const CFont* fontUsed = iEikonEnv->LegendFont();
	iHsgLableOpenTitle->SetFont(fontUsed);
	//导入中文资源
	TBuf<32> sPhoneNumLabelTitle;		
	CEikonEnv::Static()->ReadResource(sPhoneNumLabelTitle,R_QTN_HEWB_LXD_TITLE);
	//设置Label显示内容
	iHsgLableOpenTitle->SetTextL(sPhoneNumLabelTitle);
	iHsgLableOpenTitle->SetExtent(TPoint(aRect.Width()/30,aRect.Height()/7), iHsgLableOpenTitle->MinimumSize());

	// 	动态创建内容Label

	iHsgLableOpenContent = new(ELeave) CEikLabel;		
	iHsgLableOpenContent->SetContainerWindowL(*this);
	iHsgLableOpenContent->SetFont(fontUsed);
	//导入中文资源
	TBuf<32> sPhoneNumLabelContent;		
	CEikonEnv::Static()->ReadResource(sPhoneNumLabelContent, R_QTN_HEWB_LXD_CONTENT);
	//设置Label显示内容
	iHsgLableOpenContent->SetTextL(sPhoneNumLabelContent);
	iHsgLableOpenContent->SetExtent(TPoint(aRect.Width()/30,aRect.Height()/7+fontUsed->HeightInPixels()+10+aRect.Height()/14+10), iHsgLableOpenContent->MinimumSize());


	//动态创建标题Editor
	iHsgEditorOpenTitle = new(ELeave) CEikEdwin;
	iHsgEditorOpenTitle->SetContainerWindowL(*this);
	iHsgEditorOpenTitle->ConstructL(EAknEditorFlagDefault, 1, 16, 1);
	//设置editor显示位置、大小
	iHsgEditorOpenTitle->SetExtent(TPoint(aRect.Width()/30,aRect.Height()/7+(fontUsed->HeightInPixels())+10),TSize(aRect.Width()-aRect.Width()/15,aRect.Height()/14));
	//设置当前输入模式
	iHsgEditorOpenTitle->SetAknEditorCurrentInputMode(EAknEditorNumericInputMode);
	iHsgEditorOpenTitle->SetFocus(ETrue);

	//动态创建内容Editor
	iHsgEditorOpenContent = new(ELeave) CEikEdwin;
	iHsgEditorOpenContent->SetContainerWindowL(*this);
	iHsgEditorOpenContent->ConstructL(EAknEditorFlagDefault, 1, 72, 10);
	//设置editor显示位置、大小
	iHsgEditorOpenContent->SetExtent(TPoint(aRect.Width()/30,aRect.Height()/7+2*(fontUsed->HeightInPixels())+aRect.Height()/14+30),TSize(aRect.Width()-aRect.Width()/15,aRect.Height()*5/7-2*(fontUsed->HeightInPixels())-30-aRect.Height()/14));
	//设置当前输入模式
	iHsgEditorOpenContent->SetAknEditorCurrentInputMode(EAknEditorNumericInputMode);

//****************************************************************************************
	CCJGProjectAppUi* pAppUi = (CCJGProjectAppUi*)CCoeEnv::Static()->AppUi();
	iOpenMesLabel = new(ELeave)CNewsRollText;
	iOpenMesLabel->SetContainerWindowL(*this);
	CLxdAD* ilxdpointer=pAppUi->LxdGetADPointer();
	HBufC* buf=ilxdpointer->LxdGetAD(2);

	iOpenMesLabel->NewsSetTextL(buf->Des());//显示中文滚动文字
	iOpenMesLabel->NewsSetBackgroundColor(TRgb(159,203,223));
	TSize sz = iOpenMesLabel->MinimumSize();
	iOpenMesLabel->NewsSetExtent( TPoint(0,0), sz);
	iOpenMesLabel->Start();
//*********************************************************************
	iLxdOpenPointer=pAppUi->LxdGetMessage();
	TInt mLxdIndex;
	pAppUi->GetHsgTextView()->LxdGetIndex(mLxdIndex);
	iLxdOpenPointer->LxdSetId(mLxdIndex);
	TBuf<10> mTime;
	TBuf<50> mTitle;
	TBuf<200> mContent;
	iLxdOpenPointer->LxdGetMessage(mTime,mTitle,mContent);
	HsgSetOpenTitle(mTitle);
	HsgSetOpenContent(mContent);

    ActivateL();
}

// destructor
CHsgOpenTextContainer::~CHsgOpenTextContainer()
{
	MEMORY_FREE(iHsgLableOpenTitle);
	MEMORY_FREE(iHsgLableOpenContent);
	MEMORY_FREE(iHsgEditorOpenTitle);
	MEMORY_FREE(iHsgEditorOpenContent);
	MEMORY_FREE(iOpenMesLabel);
}

void CHsgOpenTextContainer::SizeChanged()
{
}

// ---------------------------------------------------------
// CHsgOpenTextContainer::CountComponentControls() const
// return the number of controls
// ---------------------------------------------------------
//
TInt CHsgOpenTextContainer::CountComponentControls() const
{
	// return number of controls inside this container
	return 5; 
}

// ---------------------------------------------------------
// CHsgOpenTextContainer::ComponentControl(TInt aIndex) const
// return the pointer to specified control.
// ---------------------------------------------------------
//
CCoeControl* CHsgOpenTextContainer::ComponentControl( TInt aIndex ) const
{
	switch (aIndex)
	{
	case 0:
		return iHsgLableOpenTitle;
	case 1:
		return iHsgLableOpenContent;
	case 2:
		return iHsgEditorOpenTitle;
	case 3:
		return iHsgEditorOpenContent;
	case 4:
		return iOpenMesLabel;
	default:
		return NULL;
	}
	return NULL;
}

// ---------------------------------------------------------
// CHsgOpenTextContainer::Draw(const TRect& aRect) const
// handle the message when client region must be redrawn.
// ---------------------------------------------------------
//
void CHsgOpenTextContainer::Draw( const TRect& aRect ) const
{
	CWindowGc& gc = SystemGc();
	gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
	gc.SetBrushColor(KRgbRed);
	gc.DrawRect(Rect());

	gc.SetPenStyle(CGraphicsContext::ESolidPen);	
	gc.SetPenColor(KRgbBlack);
	const CFont* fontUsed = iEikonEnv->LegendFont();//获取中文字体
	gc.UseFont(fontUsed);

	TBuf<8> aBufReturn;
	CEikonEnv::Static()->ReadResource(aBufReturn,R_QTN_CJG_SNOW_RETURN);

	TPoint pointRight(aRect.Width()-fontUsed->TextWidthInPixels(aBufReturn),aRect.Height());

	gc.DrawText(aBufReturn,pointRight);
}

// ---------------------------------------------------------
// CAknExGridContainer::OfferKeyEventL(
//           const TKeyEvent& aKeyEvent, TEventCode aType )
// Handles the key events.
// ---------------------------------------------------------
//
TKeyResponse CHsgOpenTextContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType )
{
	if((aType == EEventKey) && ((aKeyEvent.iCode == EKeyDevice0)||(aKeyEvent.iCode == EKeyDevice3)))
	{
		CCJGProjectAppUi* pAppUi = (CCJGProjectAppUi*)CCoeEnv::Static()->AppUi();
		pAppUi->NewsGetHsgOpenTextView()->HandleCommandL(0);
	}
	if((aType == EEventKey) && (aKeyEvent.iCode == EKeyDevice1))
	{
		CCJGProjectAppUi* pAppUi = (CCJGProjectAppUi*)CCoeEnv::Static()->AppUi();
		pAppUi->NewsGetHsgOpenTextView()->HandleCommandL(1);
	}
		if (iHsgEditorOpenTitle->IsFocused())
		{
			if((aType == EEventKey) && (aKeyEvent.iCode == EKeyDownArrow))
			{
				iHsgEditorOpenTitle->SetFocus(EFalse);
				iHsgEditorOpenContent->SetFocus(ETrue);
				return EKeyWasNotConsumed;
			}
			return iHsgEditorOpenTitle->OfferKeyEventL(aKeyEvent, aType);
		}
	if (iHsgEditorOpenContent)
	{
		if (iHsgEditorOpenContent->IsFocused())
		{
			if((aType == EEventKey) && (aKeyEvent.iCode == EKeyUpArrow))
			{
				iHsgEditorOpenContent->SetFocus(EFalse);
				iHsgEditorOpenTitle->SetFocus(ETrue);
				return EKeyWasNotConsumed;
			}
			return iHsgEditorOpenContent->OfferKeyEventL(aKeyEvent, aType);
		}
	}
	return EKeyWasNotConsumed;
}

void CHsgOpenTextContainer::HsgSetOpenTitle(const TDesC &aTitle)
{
  iHsgEditorOpenTitle->SetTextL(&aTitle);
}
void CHsgOpenTextContainer::HsgSetOpenContent(const TDesC &aContent)
{
	iHsgEditorOpenContent->SetTextL(&aContent);

}

// End of File  

⌨️ 快捷键说明

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