?? newtxtcontainer.cpp
字號:
/*
* ============================================================================
* Name : CNewTxtContainer from CCoeControl, MCoeControlObserver
* Part of : Hello
* Copyright (c) 2003 Nokia. All rights reserved.
* ============================================================================
*/
// INCLUDE FILES
#include <EveryDay.rsg>
#include "EveryDay.hrh"
#include "NewTxtContainer.h"
#include <eiklabel.h>
#include <eikedwin.h>
#include <aknnotewrappers.h>
// ================= MEMBER FUNCTIONS =======================
// C++ default constructor can NOT contain any code, that
// might leave.
//
CNewTxtContainer::CNewTxtContainer()
{
m_pNewLabel = NULL;
m_pNewLabel1 = NULL;
m_pNewEdit = NULL;
m_pNewEdit1 = NULL;
}
// EPOC default constructor can leave.
void CNewTxtContainer::ConstructL(const TRect& aRect)
{
CreateWindowL();
//Label
m_pNewLabel = new(ELeave) CEikLabel;
m_pNewLabel->SetContainerWindowL(*this);
TBuf<32> buf;
CEikonEnv::Static()->ReadResource(buf, R_QTN_NEWTXT_NEXTITLE);
m_pNewLabel->SetTextL(buf);
m_pNewLabel->SetExtent(TPoint(10,20), m_pNewLabel->MinimumSize());
//Label1
m_pNewLabel1 = new(ELeave) CEikLabel;
m_pNewLabel1->SetContainerWindowL(*this);
CEikonEnv::Static()->ReadResource(buf, R_QTN_NEWTXT_CONTENT);
m_pNewLabel1->SetTextL(buf);
m_pNewLabel1->SetExtent(TPoint(10,50), m_pNewLabel1->MinimumSize());
//Edit
m_pNewEdit = new(ELeave) CEikEdwin;
m_pNewEdit->SetContainerWindowL(*this);
m_pNewEdit->ConstructL(EAknEditorFlagDefault, 10, 10, 1);
m_pNewEdit->SetExtent(TPoint(55,20), TSize(80,20));
m_pNewEdit->SetTextL(&_L("Input Title!"));
m_pNewEdit->SetFocus(ETrue);
//Edit1
m_pNewEdit1 = new(ELeave) CEikEdwin;
m_pNewEdit1->SetContainerWindowL(*this);
m_pNewEdit1->ConstructL(EAknEditorFlagDefault, 10, 100, 1);
m_pNewEdit1->SetExtent(TPoint(40,50), TSize(120,80));
m_pNewEdit1->SetTextL(&_L("Input content!"));
SetRect(aRect);
ActivateL();
}
// Destructor
CNewTxtContainer::~CNewTxtContainer()
{
MEM_FREE(m_pNewLabel);
MEM_FREE(m_pNewLabel1);
MEM_FREE(m_pNewEdit);
MEM_FREE(m_pNewEdit1);
}
// ---------------------------------------------------------
// CNewTxtContainer::FocusTo(TInt aCommand)
// Change foccused control.
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CNewTxtContainer::FocusTo(TInt aCommand)
{
}
// ---------------------------------------------------------
// CNewTxtContainer::SizeChanged()
// Called by framework when the view size is changed
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CNewTxtContainer::SizeChanged()
{
}
// ---------------------------------------------------------
// CNewTxtContainer::CountComponentControls() const
// (other items were commented in a header).
// ---------------------------------------------------------
//
TInt CNewTxtContainer::CountComponentControls() const
{
return 4; // return nbr of controls inside this container
}
// ---------------------------------------------------------
// CNewTxtContainer::ComponentControl(TInt aIndex) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
CCoeControl* CNewTxtContainer::ComponentControl(TInt aIndex) const
{
switch (aIndex)
{
case 0:
{
return m_pNewLabel;
break;
}
case 1:
{
return m_pNewLabel1;
break;
}
case 2:
{
return m_pNewEdit;
break;
}
case 3:
{
return m_pNewEdit1;
break;
}
default:
{
return NULL;
break;
}
}
}
// ---------------------------------------------------------
// CNewTxtContainer::Draw(const TRect& aRect) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CNewTxtContainer::Draw(const TRect& aRect) const
{
CWindowGc& gc = SystemGc();
gc.SetBrushColor(KRgbWhite);
gc.SetPenStyle(CGraphicsContext::ENullPen);
gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
gc.DrawRect(aRect);
gc.SetPenStyle(CGraphicsContext::ESolidPen);
gc.SetPenColor(KRgbBlack);
TRect rec;
rec.iTl=TPoint(53,18);
rec.iBr=TPoint(150,42);
gc.DrawRect(rec);
rec.iTl=TPoint(38,48);
rec.iBr=TPoint(162,132);
gc.DrawRect(rec);
}
// ---------------------------------------------------------
// CNewTxtContainer::OfferKeyEventL(...)
// Notify key events to editors.
// (other items were commented in a header).
// ---------------------------------------------------------
//
TKeyResponse CNewTxtContainer::OfferKeyEventL(
const TKeyEvent& aKeyEvent, TEventCode aType)
{
if (m_pNewEdit)
{
if (m_pNewEdit->IsFocused())
{
if((aType == EEventKey) && (aKeyEvent.iCode == EKeyDownArrow))
{
m_pNewEdit->SetFocus(EFalse);
m_pNewEdit1->SetFocus(ETrue);
return EKeyWasConsumed;
}
return m_pNewEdit->OfferKeyEventL(aKeyEvent, aType);
}
}
if (m_pNewEdit1)
{
if (m_pNewEdit1->IsFocused())
{
if((aType == EEventKey) && (aKeyEvent.iCode == EKeyUpArrow))
{
m_pNewEdit->SetFocus(ETrue);
m_pNewEdit1->SetFocus(EFalse);
return EKeyWasConsumed;
}
return m_pNewEdit1->OfferKeyEventL(aKeyEvent, aType);
}
}
return EKeyWasNotConsumed;
}
// ---------------------------------------------------------
// CNewTxtContainer::HandleControlEventL(
// CCoeControl* aControl,TCoeEvent aEventType)
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CNewTxtContainer::HandleControlEventL(
CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
{
}
// End of File
TInt CNewTxtContainer::GetTitle()
{
TBuf<32> title;
m_pNewEdit->GetText(title);
TInt num = title.Length();
return num;
}
void CNewTxtContainer::GetTitle(TDes& title)
{
m_pNewEdit->GetText(title);
}
void CNewTxtContainer::GetContext(TDes& context)
{
m_pNewEdit1->GetText(context);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -