📄 createmescontainer.cpp
字号:
/*
* ============================================================================
* Name : CCreateMesContainer from CCoeControl, MCoeControlObserver
* Part of : CreateMes
* Copyright (c) 2003 Nokia. All rights reserved.
* ============================================================================
*/
// INCLUDE FILES
#include <eiklabel.h> // for example label control
#include <barsread.h> // for resource reader
#include <eikedwin.h> // for CEikEdwin
#include <eikgted.h> // for CEikGlobalTextEditor
#include <FrMes.rsg>
#include "FrMes.hrh"
#include "CreateMesContainer.h"
#include <gulcolor.h>
#include "FrMesAppUi.h"
#include "MessageDB.h"
#include <aknquerydialog.h>
#include "msvids.h"
// ================= MEMBER FUNCTIONS =======================
// C++ default constructor can NOT contain any code, that
// might leave.
//
CCreateMesContainer::CCreateMesContainer()
{
m_pLabelName = NULL;
m_pEditName = NULL;
m_pEditMessage = NULL;
}
// EPOC default constructor can leave.
void CCreateMesContainer::ConstructL(const TRect& aRect)
{
CreateWindowL();
//label sName
TBuf<32> sName;
iCoeEnv->ReadResource(sName, R_QTN_FRMES_CREATEMES_NAME);
m_pLabelName = new (ELeave) CEikLabel;
m_pLabelName->SetContainerWindowL(*this);
m_pLabelName->SetTextL(sName);
m_pLabelName->SetExtent(TPoint(20, 15),m_pLabelName->MinimumSize());
//edit sName new
m_pEditName = new (ELeave) CEikEdwin(/*TGulBorder::ESingleBlack*/);
m_pEditName->SetContainerWindowL(*this);
m_pEditName->ConstructL(EEikEdwinNoAutoSelection | EEikEdwinIgnoreVirtualCursor, 10, 16, 1);
m_pEditName->SetExtent(TPoint(67, 13), TSize(80, 20));
m_pEditName->SetAknEditorInputMode(EAknEditorNumericInputMode);
m_pEditName->SetFocus(ETrue);
//edit sMessage new
m_pEditMessage = new (ELeave) CEikEdwin(/*TGulBorder::ESingleBlack*/);
m_pEditMessage->SetAknEditorFlags(EAknEditorFlagEnableScrollBars);
m_pEditMessage->SetContainerWindowL(*this);
m_pEditMessage->ConstructL(EAknEditorFlagDefault, 10, 70, 7);
m_pEditMessage->SetExtent(TPoint(18,50),TSize(140,82));
SetRect(aRect);
ActivateL();
}
// Destructor
CCreateMesContainer::~CCreateMesContainer()
{
if(m_pLabelName)
{
delete m_pLabelName;
m_pLabelName = NULL;
}
if(m_pEditName)
{
delete m_pEditName;
m_pEditName = NULL;
}
if (m_pEditMessage)
{
delete m_pEditMessage;
m_pEditMessage = NULL;
}
}
// ---------------------------------------------------------
// CCreateMesContainer::FocusTo(TInt aCommand)
// Change foccused control.
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CCreateMesContainer::FocusTo(TInt aCommand)
{
}
// ---------------------------------------------------------
// CCreateMesContainer::SizeChanged()
// Called by framework when the view size is changed
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CCreateMesContainer::SizeChanged()
{
}
// ---------------------------------------------------------
// CCreateMesContainer::CountComponentControls() const
// (other items were commented in a header).
// ---------------------------------------------------------
//
TInt CCreateMesContainer::CountComponentControls() const
{
return 3; // return nbr of controls inside this container
}
// ---------------------------------------------------------
// CCreateMesContainer::ComponentControl(TInt aIndex) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
CCoeControl* CCreateMesContainer::ComponentControl(TInt aIndex) const
{
switch(aIndex)
{
case 0:
return m_pLabelName;
break;
case 1:
return m_pEditName;
break;
case 2:
return m_pEditMessage;
break;
default:
return NULL;
break;
}
}
// ---------------------------------------------------------
// CCreateMesContainer::Draw(const TRect& aRect) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CCreateMesContainer::Draw(const TRect& aRect) const
{
CWindowGc& gc = SystemGc();
// gc.SetPenStyle(CGraphicsContext::ENullPen);
// gc.SetBrushColor(KRgbGray);
// gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
// gc.DrawRect(aRect);
gc.Clear(aRect);
gc.SetBrushStyle(CGraphicsContext::ENullBrush);
gc.SetPenColor(KRgbDarkBlue);
gc.SetPenStyle(CGraphicsContext::ESolidPen);
TRect rc;
rc.SetRect(TPoint(15,10), TSize(146, 25));
gc.DrawRect(rc);
rc.SetRect(TPoint(15,44),TSize(146,92));
gc.DrawRect(rc);
}
// ---------------------------------------------------------
// CCreateMesContainer::OfferKeyEventL(...)
// Notify key events to editors.
// (other items were commented in a header).
// ---------------------------------------------------------
//
TKeyResponse CCreateMesContainer::OfferKeyEventL(
const TKeyEvent& aKeyEvent, TEventCode aType)
{
if (m_pEditName)
{
if (m_pEditName->IsFocused())
{
if((aType == EEventKey) && (aKeyEvent.iCode == EKeyDownArrow))
{
m_pEditName->SetFocus(EFalse);
m_pEditMessage->SetFocus(ETrue);
return EKeyWasConsumed;
}
return m_pEditName->OfferKeyEventL(aKeyEvent, aType);
}
}
if (m_pEditMessage)
{
if (m_pEditMessage->IsFocused())
{
if((aType == EEventKey)
&& (aKeyEvent.iCode == EKeyUpArrow)
&& (m_pEditMessage->CursorPos() == 0))
{
m_pEditMessage->SetFocus(EFalse);
m_pEditName->SetFocus(ETrue);
m_pEditName->SetAknEditorInputMode(EAknEditorNumericInputMode);
return EKeyWasConsumed;
}
return m_pEditMessage->OfferKeyEventL(aKeyEvent, aType);
}
}
return EKeyWasNotConsumed;
}
// ---------------------------------------------------------
// CCreateMesContainer::HandleControlEventL(
// CCoeControl* aControl,TCoeEvent aEventType)
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CCreateMesContainer::HandleControlEventL(
CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
{
}
void CCreateMesContainer::GetInput (TDes& aName, TDes& aCode)
{
m_pEditName->GetText(aName);
m_pEditMessage->GetText(aCode);
return;
}
void CCreateMesContainer::GetInputL (HBufC*& aName, HBufC*& aContent)
{
TBuf<16> Name;
TBuf<70> Content;
m_pEditName->GetText(Name);
m_pEditMessage->GetText(Content);
aName = HBufC::NewLC(Name.Length()+1);
aContent = HBufC::NewLC(Content.Length()+1);
TPtr16 ptr16Name = aName->Des();
TPtr16 ptr16Content = aContent->Des();
CleanupStack::Pop(2);
ptr16Name.Copy(Name);
ptr16Content.Copy(Content);
return;
}
void CCreateMesContainer::SetTextL(TDesC * aPhone,TDesC * aMessage)
{
m_pEditName->SetTextL(aPhone);
m_pEditMessage->SetTextL(aMessage);
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -