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

📄 smseditcontainer.cpp

📁 symbian 2rd 备忘录
💻 CPP
字号:

#include <gulicon.h>
#include <aknutils.h>    // definition of AKN_LAF_COLOR()
#include <avkon.hrh>
#include <akntitle.h>
#include <aknnotewrappers.h>
#include <eiklabel.h>
#include <eikedwin.h>

#include "SMSEditContainer.h"
#include "Assistant.rsg"
#include "SMSEditView.h"
#include "Assistant.hrh"

//////////////////////////////////////////////////////////////////////////
CSMSEditContainer::CSMSEditContainer()
{
	m_pLabelMobile = NULL;
	m_pLabelContent = NULL;
	m_pEditMobile = NULL;
	m_pEditContent = NULL;
	m_pMessagView = NULL;
}

// EPOC default constructor can leave.
void CSMSEditContainer::ConstructL(const TRect& aRect,CSMSEditView* aView)
{
    CreateWindowL();
	m_pMessagView = aView;

	TBuf<32> sTmpLabel;
	
	//create Mobile label
	m_pLabelMobile = new( ELeave ) CEikLabel;
	m_pLabelMobile->SetContainerWindowL( *this );
	m_pLabelMobile->SetExtent(TPoint(7,15), TSize(40,18)); 	
	CEikonEnv::Static()->ReadResource(sTmpLabel, R_QTN_ASSISTANT_TO);
	m_pLabelMobile->SetTextL(sTmpLabel);
	
	//create Mobile edit 
	m_pEditMobile = new (ELeave) CEikEdwin;
	m_pEditMobile->SetContainerWindowL(*this);
	m_pEditMobile->ConstructL(EAknEditorFlagDefault, 11, 11, 11);
	m_pEditMobile->SetAknEditorCurrentInputMode(EAknEditorNumericInputMode);
	m_pEditMobile->SetExtent(TPoint(50, 15),TSize(120,18));
	m_pEditMobile->SetFocus(ETrue);
	
	//create Mobile label
	m_pLabelContent = new( ELeave ) CEikLabel;
	m_pLabelContent->SetContainerWindowL( *this );
	m_pLabelContent->SetExtent(TPoint(7,35), TSize(9,3)); 
	sTmpLabel.Copy(_L(""));
	m_pLabelContent->SetTextL(sTmpLabel);
	
	
	//create Content edit 
	m_pEditContent = new (ELeave) CEikEdwin;
	m_pEditContent->SetContainerWindowL(*this);
	m_pEditContent->ConstructL(EAknEditorFlagDefault, 100, 100, 15);
//	m_pEditContent->SetAknEditorCurrentInputMode(EAknEditorTextInputMode);	//此句为ABC输入法,注销掉使用默认的拼音输入法
	m_pEditContent->SetExtent(TPoint(7, 45),TSize(163,86));
//	m_pEditContent->SetFocus(ETrue);

    SetRect( aRect );
    ActivateL();
}
void CSMSEditContainer::ChangeLabel()
{
	TBuf<32> sTmpLabel;
	//create Mobile label
	CEikonEnv::Static()->ReadResource(sTmpLabel, R_QTN_ASSISTANT_FROM);
	m_pLabelMobile->SetTextL(sTmpLabel);
}
// destructor
CSMSEditContainer::~CSMSEditContainer()
{
	MEMORY_FREE(m_pLabelMobile);
	MEMORY_FREE(m_pEditMobile);
	MEMORY_FREE(m_pLabelContent);
	MEMORY_FREE(m_pEditContent);

}

void CSMSEditContainer::SizeChanged()
{
}

// ---------------------------------------------------------
// CMessageContainer::CountComponentControls() const
// return the number of controls
// ---------------------------------------------------------
//
TInt CSMSEditContainer::CountComponentControls() const
{
	// return number of controls inside this container
	return 4; 
}

// ---------------------------------------------------------
// CMessageContainer::ComponentControl(TInt aIndex) const
// return the pointer to specified control.
// ---------------------------------------------------------
//
CCoeControl* CSMSEditContainer::ComponentControl( TInt aIndex ) const
{
	switch(aIndex)
	{
	case 0:
		return m_pLabelMobile;
	case 1:
		return m_pEditMobile;
	case 2:
		return m_pLabelContent;
 	case 3:
 		return m_pEditContent;
	}
	return NULL;
}

// ---------------------------------------------------------
// CMessageContainer::Draw(const TRect& aRect) const
// handle the message when client region must be redrawn.
// ---------------------------------------------------------
//
void CSMSEditContainer::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(KRgbGray);

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

	//Mobile -----  长方形
// 	gc.SetPenStyle(CGraphicsContext::ESolidPen);
// 	gc.SetPenColor(KRgbBlack);
	TRect rect1;
	rect1.iTl = TPoint(49,13);
	rect1.iBr = TPoint(171 ,34);
	gc.DrawRect(rect1);

 	//Content ------- 长方形
// 	gc.SetPenStyle(CGraphicsContext::ESolidPen);
// 	gc.SetPenColor(KRgbBlack);
	TRect rect2;
	rect2.iTl = TPoint(6,43);
	rect2.iBr = TPoint(171,134);
	gc.DrawRect(rect2);
	
}

// ---------------------------------------------------------
// CAknExGridContainer::OfferKeyEventL(
//           const TKeyEvent& aKeyEvent, TEventCode aType )
// Handles the key events.
// ---------------------------------------------------------
//
TKeyResponse CSMSEditContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType )
{
	if (m_pEditMobile)
	{
		if (m_pEditMobile->IsFocused())
		{
			if((aType == EEventKey) && (aKeyEvent.iCode == EKeyDownArrow))
			{
				m_pEditMobile->SetFocus(EFalse);
				m_pEditContent->SetFocus(ETrue);
				return EKeyWasConsumed;
			}
			if (aKeyEvent.iCode == 0XF845)
			{
				m_pMessagView->HandleCommandL(EAssistantOk);
				return EKeyWasConsumed;
			}
			return m_pEditMobile->OfferKeyEventL(aKeyEvent, aType);
		}
	}
	if (m_pEditContent)
	{
		if (m_pEditContent->IsFocused())
		{
			if((aType == EEventKey) && (aKeyEvent.iCode == EKeyUpArrow))
			{
				m_pEditContent->SetFocus(EFalse);
				m_pEditMobile->SetFocus(ETrue);	
				return EKeyWasConsumed;
			}
			if (aKeyEvent.iCode == 0XF845)
			{
				m_pMessagView->HandleCommandL(EAssistantSend);
				return EKeyWasConsumed;
			}
			return m_pEditContent->OfferKeyEventL(aKeyEvent, aType);
		}
	}
  return EKeyWasConsumed;
}

void CSMSEditContainer::SetData(const TDesC& aMobile, const TDesC& aContent)
{
	m_pEditMobile->SetTextL(&aMobile);
	m_pEditContent->SetTextL(&aContent);
}
void CSMSEditContainer::GetData(TDes& aMobile, TDes& aContent)
{
	m_pEditMobile->GetText(aMobile);
	m_pEditContent->GetText(aContent);
}
void CSMSEditContainer::SetReadOnly(TInt aStatus)
{
	if ( aStatus !=EAssistantStatusNew && aStatus != EAssistantStatusDraft)
	{
		m_pEditMobile->SetReadOnly(ETrue); //只读
		m_pEditContent->SetReadOnly(ETrue); //只读
	}
	else
	{
		m_pEditMobile->SetReadOnly(EFalse); 
		m_pEditContent->SetReadOnly(EFalse); 
	}
}



⌨️ 快捷键说明

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