📄 modifynotecontainer.cpp.bak
字号:
/*
* ============================================================================
* Name : CModifyNoteContainer from CCoeControl, MCoeControlObserver
* Part of : ModifyNote
* Copyright (c) 2003 Nokia. All rights reserved.
* ============================================================================
*/
// INCLUDE FILES
#include <HelperGenius.rsg>
#include "HelperGenius.hrh"
#include "ModifyNoteContainer.h"
#include <eiklabel.h>
#include <eikedwin.h>
#include <barsread.h>
#include <eikenv.h>
#include <Helpergenius.mbg>
#include <fbs.h>
#include <AknUtils.h>
// ================= MEMBER ModifyNoteS =======================
// C++ default constructor can NOT contain any code, that
// might leave.
//
#define DELPTR(p) if(p!=NULL){ delete p;p=NULL;}
CModifyNoteContainer::CModifyNoteContainer()
{
m_pLabelTitle = NULL;
m_pEditTitle = NULL;
m_pLabelContent = NULL;
m_pEditContent = NULL;
m_pBitmap = NULL;
}
// EPOC default constructor can leave.
void CModifyNoteContainer::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_ADD_CAPTION );
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_ADD_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,10,1);
m_pEditTitle->SetExtent(TPoint(8,16),TSize(160,20));
// m_pEditTitle->SetTextL(&_L(""));
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));
// m_pEditContent->SetTextL(&_L(""));
CleanupStack::Pop( m_pEditContent );
SetRect(aRect);
ActivateL();
}
// Destructor
CModifyNoteContainer::~CModifyNoteContainer()
{
DELPTR(m_pLabelTitle);
DELPTR(m_pEditTitle);
DELPTR(m_pLabelContent);
DELPTR(m_pEditContent);
DELPTR(m_pBitmap);
}
// ---------------------------------------------------------
// CModifyNoteContainer::FocusTo(TInt aCommand)
// Change foccused control.
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CModifyNoteContainer::FocusTo(TInt aCommand)
{
}
// ---------------------------------------------------------
// CModifyNoteContainer::SizeChanged()
// Called by framework when the view size is changed
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CModifyNoteContainer::SizeChanged()
{
}
// ---------------------------------------------------------
// CModifyNoteContainer::CountComponentControls() const
// (other items were commented in a header).
// ---------------------------------------------------------
//
TInt CModifyNoteContainer::CountComponentControls() const
{
return 4; // return nbr of controls inside this container
}
// ---------------------------------------------------------
// CModifyNoteContainer::ComponentControl(TInt aIndex) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
CCoeControl* CModifyNoteContainer::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;
}
}
}
// ---------------------------------------------------------
// CModifyNoteContainer::Draw(const TRect& aRect) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CModifyNoteContainer::Draw(const TRect& aRect) const
{
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)));
}
// ---------------------------------------------------------
// CModifyNoteContainer::OfferKeyEventL(...)
// Notify key events to editors.
// (other items were commented in a header).
// ---------------------------------------------------------
//
TKeyResponse CModifyNoteContainer::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;
}
// ---------------------------------------------------------
// CModifyNoteContainer::HandleControlEventL(
// CCoeControl* aControl,TCoeEvent aEventType)
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CModifyNoteContainer::HandleControlEventL(
CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
{
}
CEikEdwin* CModifyNoteContainer::GetEditTitle()
{
return m_pEditTitle;
}
CEikEdwin* CModifyNoteContainer::GetEdContent()
{
return m_pEditContent;
}
void CModifyNoteContainer::GetNewTitle(TDes& aTitle)
{
m_pEditTitle->GetText(aTitle);
}
void CModifyNoteContainer::GetNewContent(TDes& aContent)
{
m_pEditContent->GetText(aContent);
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -