📄 smsoperationcontainer.cpp
字号:
/*
* ============================================================================
* Name : CSMSOperationContainer from CCoeControl, MCoeControlObserver
* Part of : SMSOperation
* Copyright (c) 2003 Nokia. All rights reserved.
* ============================================================================
*/
#define MEM_FREE(p) if (NULL!=p){delete p; p = NULL;}
// INCLUDE FILES
#include "SMSOperationContainer.h"
#include <FairyLand.rsg>
#include "FairyLand.hrh"
#include <eikenv.h>
#include <FairyLand.rsg>
#include <eiklabel.h>
#include <eikedwin.h> //for CEikEdwin
// #include <aknsdrawutils.h>
// #include <aknsbasicbackgroundcontrolcontext.h>
#include <barsread.h> //for resource reader
// ================= MEMBER FUNCTIONS =======================
// C++ default constructor can NOT contain any code, that
// might leave.
//
CSMSOperationContainer::CSMSOperationContainer()
{
iLabel1=NULL;
iLabel2=NULL;
iEdit1=NULL;
iEdit2=NULL;
}
// EPOC default constructor can leave.
void CSMSOperationContainer::ConstructL(const TRect& aRect)
{
CreateWindowL();
//Label
iLabel1=new(ELeave) CEikLabel;
iLabel1->SetContainerWindowL(*this);
TBuf<20> buf1;
CEikonEnv::Static()->ReadResource(buf1, R_QTN_IM_DETAIL_SENDER);
iLabel1->SetTextL(buf1);
iLabel1->SetExtent(TPoint(10,10), iLabel1->MinimumSize());
//Labe2
iLabel2=new(ELeave) CEikLabel;
iLabel2->SetContainerWindowL(*this);
TBuf<20> buf2;
CEikonEnv::Static()->ReadResource(buf2, R_QTN_MH_CONTENT);
iLabel2->SetTextL(buf2);
iLabel2->SetExtent(TPoint(10,40), iLabel2->MinimumSize());
//Edit1
iEdit1 = new(ELeave) CEikEdwin;
iEdit1->SetContainerWindowL(*this);
iEdit1->ConstructL(EAknEditorFlagDefault, 10, 11, 1);
iEdit1->SetAknEditorCurrentInputMode(EAknEditorNumericInputMode);
iEdit1->SetAknEditorAllowedInputModes(2);
iEdit1->SetExtent(TPoint(55,10), TSize(110,20));
iEdit1->SetFocus(ETrue);
//Edit2
TResourceReader reader;
iCoeEnv->CreateResourceReaderLC(reader, R_AKNEXEDITOR_HELLO_VIEW_EDWIN);
iEdit2 = new(ELeave) CEikEdwin;
iEdit2->SetContainerWindowL(*this);
iEdit2->ConstructFromResourceL(reader);
CleanupStack::PopAndDestroy();
// iEdit2->SetAknEditorCurrentInputMode(EAknEditorNullInputMode);
iEdit2->SetExtent(TPoint(10,40), TSize(156,100));
// iEdit2 = new(ELeave) CEikEdwin;
// iEdit2->SetContainerWindowL(*this);
// iEdit2->ConstructL(EAknEditorFlagDefault, 10, 70, 1);
// iEdit2->SetExtent(TPoint(50,40), TSize(110,90));
iEdit2->SetFocus(EFalse);
SetRect(aRect);
// iBackGround=CAknsBasicBackgroundControlContext::NewL(KAknsIIDQsnBgAreaSMSOperation,Rect(),EFalse);
ActivateL();
}
// Destructor
CSMSOperationContainer::~CSMSOperationContainer()
{
MEM_FREE(iLabel1);
MEM_FREE(iLabel2);
MEM_FREE(iEdit1);
MEM_FREE(iEdit2);
// delete iBackGround;
}
// ---------------------------------------------------------
// CSMSOperationContainer::FocusTo(TInt aCommand)
// Change foccused control.
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CSMSOperationContainer::FocusTo(TInt aCommand)
{
}
// ---------------------------------------------------------
// CSMSOperationContainer::SizeChanged()
// Called by framework when the view size is changed
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CSMSOperationContainer::SizeChanged()
{
}
// ---------------------------------------------------------
// CSMSOperationContainer::CountComponentControls() const
// (other items were commented in a header).
// ---------------------------------------------------------
//
TInt CSMSOperationContainer::CountComponentControls() const
{
return 4; // return nbr of controls inside this container
}
// ---------------------------------------------------------
// CSMSOperationContainer::ComponentControl(TInt aIndex) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
CCoeControl* CSMSOperationContainer::ComponentControl(TInt aIndex) const
{
switch(aIndex)
{
case 0:
{
return iLabel1;
break;
}
case 1:
{
return iLabel2;
break;
}
case 2:
{
return iEdit1;
break;
}
case 3:
{
return iEdit2;
break;
}
default:
{
return NULL;
break;
}
};
}
// ---------------------------------------------------------
// CSMSOperationContainer::Draw(const TRect& aRect) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CSMSOperationContainer::Draw(const TRect& aRect) const
{
CWindowGc& gc = SystemGc();
gc.SetPenStyle(CGraphicsContext::ENullPen);
gc.SetBrushColor(KRgbCyan);
gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
gc.DrawRect(aRect);
// const CFont* fon=CEikonEnv::Static()->TitleFont();
// gc.UseFont(fon);
// _LIT(KSMSOperation,R_QTN_MH_SMSOperation_CONTENT);
// TBuf<20> buf;
// CEikonEnv::Static()->ReadResource(buf, R_QTN_MH_SMSOperation_CONTENT);
// TPoint point(aRect.Width()/2-50,aRect.Height()/2);
// gc.DrawText(buf,point);
// gc.DiscardFont();
// MAknsSkinInstance* skin=AknsUtils::SkinInstance();
// MAknsControlContext* cc=AknsDrawUtils::ControlContext(this);
// AknsDrawUtils::Background(skin,cc,this,gc,aRect);
}
// ---------------------------------------------------------
// CSMSOperationContainer::OfferKeyEventL(...)
// Notify key events to editors.
// (other items were commented in a header).
// ---------------------------------------------------------
//
TKeyResponse CSMSOperationContainer::OfferKeyEventL(
const TKeyEvent& aKeyEvent, TEventCode aType)
{
if (iEdit1)
{
if (iEdit1->IsFocused())
{
if((aType == EEventKey) && (aKeyEvent.iCode == EKeyDownArrow))
{
iEdit1->SetFocus(EFalse);
iEdit2->SetFocus(ETrue);
return EKeyWasConsumed;
}
return iEdit1->OfferKeyEventL(aKeyEvent, aType);
}
}
if (iEdit2)
{
if (iEdit2->IsFocused())
{
if((aType == EEventKey) && (aKeyEvent.iCode == EKeyDownArrow)|| (aType == EEventKey) && (aKeyEvent.iCode == EKeyUpArrow))
{
iEdit2->SetFocus(EFalse);
iEdit1->SetFocus(ETrue);
return EKeyWasConsumed;
}
return iEdit2->OfferKeyEventL(aKeyEvent, aType);
}
}
return EKeyWasNotConsumed;
}
// TTypeUid::Ptr CSMSOperationContainer::MopSupplyObject(TTypeUid aId)
// {
// if (aId.iUid==MAknsControlContext::ETypeId && iBackGround)
// {
// return MAknsControlContext::SupplyMopObject(aId,iBackGround);
// }
// return CCoeControl::MopSupplyObject(aId);
// }
// ---------------------------------------------------------
// CSMSOperationContainer::HandleControlEventL(
// CCoeControl* aControl,TCoeEvent aEventType)
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CSMSOperationContainer::HandleControlEventL(
CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
{
}
void CSMSOperationContainer::GetTitle(TDes &aTitle)
{
iEdit1->GetText(aTitle);
}
void CSMSOperationContainer::GetContent(TDes &aContent)
{
iEdit2->GetText(aContent);
}
void CSMSOperationContainer::SetText(TDes& aAdress,TDesC& aContent)
{
iEdit1->SetReadOnly(false);
iEdit2->SetReadOnly(false);
iEdit1->SetTextL(&aAdress);
iEdit2->SetTextL(&aContent);
iEdit1->SetFocus(ETrue);
iEdit2->SetFocus(EFalse);
}
void CSMSOperationContainer::SetfixedText(TDes& aAdress,TDesC& aContent)
{
iEdit1->SetTextL(&aAdress);
iEdit2->SetTextL(&aContent);
iEdit1->SetReadOnly(true);
iEdit2->SetReadOnly(true);
iEdit1->SetFocus(EFalse);
iEdit2->SetFocus(EFalse);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -