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

📄 writesmscontainer.cpp

📁 个人手机助理套件:包含1、记事本(备忘录)、名片夹、名片夹的上传下载(异地备份)、短消息模块
💻 CPP
字号:
/*
* ============================================================================
*  Name     : COperateSmsContainer from CCoeControl, MCoeControlObserver
*  Part of  : OperateSms
*  Copyright (c) 2003 Nokia. All rights reserved.
* ============================================================================
*/

// INCLUDE FILES
#include <HelperGenius.rsg>
#include "HelperGenius.hrh"
#include "OperateSmsContainer.h"
#include "HelperGeniusAppUi.h"
#include <eiklabel.h>
#include <eikedwin.h>
#include <barsread.h>
#include <eikenv.h>

#include <Helpergenius.mbg>
#include <fbs.h>
#include <AknUtils.h>
// ================= MEMBER OperateSmsS =======================

// C++ default constructor can NOT contain any code, that
// might leave.
//


#define  DELPTR(p) if(p!=NULL){ delete p;p=NULL;}

COperateSmsContainer::COperateSmsContainer()
    {
       m_pLabelTitle = NULL;
       m_pEditTitle = NULL;
       m_pLabelContent = NULL;
       m_pEditContent = NULL;
       m_pBitmap = NULL;
    }

// EPOC default constructor can leave.
void COperateSmsContainer::ConstructL(const TRect& aRect)
    {
    CreateWindowL();
	m_pBitmap = new (ELeave) CFbsBitmap;
	TBuf<KMaxPath> pathMbm;
#ifdef __WINS__
	pathMbm.Copy(_L("z:\\system\\apps\\HelperGenius\\HelperGenius.mbm"));
#else
	CHelperGeniusAppUi* pApp = (CHelperGeniusAppUi*)CEikonEnv::Static()->AppUi();
	pApp->GetAppPath(pathMbm);
	
	pathMbm.Append(_L("HelperGenius.mbm"));
#endif
    User::LeaveIfError(CompleteWithAppPath(pathMbm));
    User::LeaveIfError(m_pBitmap->Load(pathMbm,EMbmHelpergeniusHelpergenius_icon_17));
    /*********设置收件人标签****************************************************/
    m_pLabelTitle = new (ELeave) CEikLabel;
    CleanupStack::PushL(m_pLabelTitle);
    m_pLabelTitle->SetContainerWindowL(*this);
    
    TBuf<32> sTmplabelName;
    CEikonEnv::Static()->ReadResource(sTmplabelName,R_QTN_MH_OPERATESMS_RECEIVER );
    m_pLabelTitle->SetTextL(sTmplabelName);
    m_pLabelTitle->SetExtent(TPoint(5,2),m_pLabelTitle->MinimumSize( ) );
    CleanupStack::Pop( m_pLabelTitle );
    /*********设置内容标签****************************************************/
    m_pLabelContent = new (ELeave) CEikLabel;
    CleanupStack::PushL(m_pLabelContent);
    m_pLabelContent->SetContainerWindowL(*this);
    
    TBuf<32> sTmplabelContent;
    CEikonEnv::Static()->ReadResource( sTmplabelContent,R_QTN_MH_OperateSms_CONTENT );
    m_pLabelContent->SetTextL(sTmplabelContent);
    m_pLabelContent->SetExtent(TPoint(5,36),m_pLabelContent->MinimumSize( ) );
    CleanupStack::Pop( m_pLabelContent );
    /*************设置联系人编辑框************************************************/
    m_pEditTitle = new(ELeave) CEikEdwin;
    CleanupStack::PushL(m_pEditTitle);
    m_pEditTitle->SetContainerWindowL(*this);    
    m_pEditTitle->ConstructL(EAknEditorFlagDefault,10,100,1);	
    m_pEditTitle->SetExtent(TPoint(8,16),TSize(160,20));    
    m_pEditTitle->SetFocus(ETrue); 
    CleanupStack::Pop( m_pEditTitle );
    /*************设置内容编辑框************************************************/
    m_pEditContent = new(ELeave) CEikEdwin;
    CleanupStack::PushL(m_pEditContent);
    m_pEditContent->SetContainerWindowL(*this);    
    m_pEditContent->ConstructL(EAknEditorFlagDefault,10,500,1);
    m_pEditContent->SetExtent(TPoint(8,50),TSize(160,90));    
    CleanupStack::Pop( m_pEditContent );

    SetRect(aRect);
    ActivateL();
    }

// Destructor
COperateSmsContainer::~COperateSmsContainer()
    {
      DELPTR(m_pLabelTitle);
      DELPTR(m_pEditTitle);
      DELPTR(m_pLabelContent);
      DELPTR(m_pEditContent);
	  DELPTR(m_pBitmap);
    }

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

void COperateSmsContainer::FocusTo(TInt aCommand)
    {
    }

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

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

// ---------------------------------------------------------
// COperateSmsContainer::ComponentControl(TInt aIndex) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
CCoeControl* COperateSmsContainer::ComponentControl(TInt aIndex) const
    {
         switch(aIndex)
	{
	case 0:
		{
			return m_pLabelTitle;
			break;
		}
	case 1:
		{
			return m_pEditTitle;
			break;
		}
	case 2:
		{
			return m_pLabelContent;
			break;
		}
	case 3:
		{
			return m_pEditContent;
			break;
		}
	default:
		{
			return NULL;
                        break;
		}
	}	
    }

// ---------------------------------------------------------
// COperateSmsContainer::Draw(const TRect& aRect) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
void COperateSmsContainer::Draw(const TRect& aRect) const
    {
//     CWindowGc& gc = SystemGc();
//     gc.SetPenStyle(CGraphicsContext::ENullPen);
//     gc.SetBrushColor(KRgbRed);
//     gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
//     gc.DrawRect(aRect);
	CWindowGc& gc = SystemGc();
	/******添加背景图片*******************************************/
    gc.Clear(aRect);
    TPoint topLeft(0,0);
	//    gc.DrawBitmap(TRect(topLeft,TSize(176,208)),m_pBitmap);
    gc.BitBlt(topLeft,m_pBitmap,TRect(topLeft,TSize(176,208)));
    }

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


// ---------------------------------------------------------
// COperateSmsContainer::HandleControlEventL(
//     CCoeControl* aControl,TCoeEvent aEventType)
// (other items were commented in a header).
// ---------------------------------------------------------
//
void COperateSmsContainer::HandleControlEventL(
											CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
{
}
void COperateSmsContainer::GetContent( TDes &aContent )
{
	m_pEditContent->GetText(aContent);
}

void COperateSmsContainer::GetAddress( TDes &aAddress )
{
	m_pEditTitle->GetText(aAddress);
}
// End of File  

⌨️ 快捷键说明

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