📄 sendingmescontainer.cpp
字号:
/*
* ============================================================================
* Name : CSendingMesContainer from CCoeControl, MCoeControlObserver
* Part of : SendingMes
* 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 <aknlists.h>
#include <FrMes.rsg>
#include "FrMes.hrh"
#include "SendingMesContainer.h"
#include "FrMesAppUi.h"
#include "akniconarray.h"
#include "MtmsEngine.h"
#include "msvids.h"
#include "MessageDB.h"
// ================= MEMBER FUNCTIONS =======================
// C++ default constructor can NOT contain any code, that
// might leave.
//
CSendingMesContainer::CSendingMesContainer()
{
m_pListBox = NULL;
m_pListBoxArray = NULL;
}
// EPOC default constructor can leave.
void CSendingMesContainer::ConstructL(const TRect& aRect)
{
CreateWindowL();
//listbox
m_pListBox = new( ELeave ) CAknDoubleGraphicStyleListBox();
CleanupStack::PushL(m_pListBox);
m_pListBox->ConstructL(this, EAknListBoxSelectionList);
m_pListBox->SetContainerWindowL( *this );
m_pListBox->SetRect(aRect);
m_pListBox->CreateScrollBarFrameL( ETrue );
m_pListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
//Add Item List
m_pListBoxArray = new (ELeave) CDesCArrayFlat(4);
CleanupStack::PushL(m_pListBoxArray);
CTextListBoxModel* model = m_pListBox->Model();
model->SetItemTextArray( m_pListBoxArray );
model->SetOwnershipType(ELbmDoesNotOwnItemArray);
CleanupStack::Pop(2);
m_pListBox->SetFocus( ETrue );
SetRect(aRect);
ActivateL();
}
// Destructor
CSendingMesContainer::~CSendingMesContainer()
{
if(m_pListBox)
{
delete m_pListBox;
m_pListBox = NULL;
}
if(m_pListBoxArray)
{
delete m_pListBoxArray;
m_pListBoxArray = NULL;
}
}
// ---------------------------------------------------------
// CSendingMesContainer::FocusTo(TInt aCommand)
// Change foccused control.
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CSendingMesContainer::FocusTo(TInt aCommand)
{
}
// ---------------------------------------------------------
// CSendingMesContainer::SizeChanged()
// Called by framework when the view size is changed
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CSendingMesContainer::SizeChanged()
{
if (m_pListBox)
{
m_pListBox->SetRect(Rect());
}
}
// ---------------------------------------------------------
// CSendingMesContainer::CountComponentControls() const
// (other items were commented in a header).
// ---------------------------------------------------------
//
TInt CSendingMesContainer::CountComponentControls() const
{
return 1; // return nbr of controls inside this container
}
// ---------------------------------------------------------
// CSendingMesContainer::ComponentControl(TInt aIndex) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
CCoeControl* CSendingMesContainer::ComponentControl(TInt aIndex) const
{
switch(aIndex)
{
case 0:
return m_pListBox;
default:
return NULL;
}
}
// ---------------------------------------------------------
// CSendingMesContainer::Draw(const TRect& aRect) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CSendingMesContainer::Draw(const TRect& aRect) const
{
CWindowGc& gc = SystemGc();
gc.SetPenStyle(CGraphicsContext::ENullPen);
gc.SetBrushColor(KRgbGray);
gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
gc.DrawRect(aRect);
}
// ---------------------------------------------------------
// CSendingMesContainer::OfferKeyEventL(...)
// Notify key events to editors.
// (other items were commented in a header).
// ---------------------------------------------------------
//
TKeyResponse CSendingMesContainer::OfferKeyEventL(
const TKeyEvent& aKeyEvent, TEventCode aType)
{
if (m_pListBox)
return m_pListBox->OfferKeyEventL (aKeyEvent, aType);
else
return EKeyWasNotConsumed;
}
// ---------------------------------------------------------
// CSendingMesContainer::HandleControlEventL(
// CCoeControl* aControl,TCoeEvent aEventType)
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CSendingMesContainer::HandleControlEventL(
CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
{
}
TInt CSendingMesContainer::GetCurrentItemIndex()
{
return m_pListBox->CurrentItemIndex();
}
void CSendingMesContainer::LoadGraphicsL()
{
CFrMesAppUi* pApp = (CFrMesAppUi*)CEikonEnv::Static()->AppUi();
TMessageDBStruct* tempMessage;
CArrayPtr< CGulIcon >* icons = new(ELeave) CAknIconArray(3);
CleanupStack::PushL( icons );
icons->AppendL(pApp->LoadGraphicsL(10));
icons->AppendL(pApp->LoadGraphicsL(8));
// Set icon array.
m_pListBox->ItemDrawer()->ColumnData()->SetIconArray( icons );
CleanupStack::Pop(); // icons array
}
void CSendingMesContainer::AddDataL()
{
//modify by wzg 08_07_15
CFrMesAppUi* pApp = (CFrMesAppUi*)CEikonEnv::Static()->AppUi();
CArrayFixFlat<TInt32>* tempArray = pApp->m_pMessageDB->
GetMessageArray(KMsvGlobalOutBoxIndexEntryId);
if(!tempArray->Count())
{
pApp->m_pMessageDB->ReadMessageToArrayL(KMsvGlobalOutBoxIndexEntryId);
}
MDesCArray* array = m_pListBox->Model()->ItemTextArray();
CDesCArray* cArray = ( CDesCArray* )array;
cArray->Reset();
TInt i;
TBuf<128> sBuf;
TMessageDBStruct* tempMessage;
for(i=0; i<tempArray->Count(); i++)
{
sBuf.Zero();
tempMessage = (TMessageDBStruct*)tempArray->At(i);
if(tempMessage->iread == _L("0"))
{
sBuf.AppendNum(0);
}
else
{
sBuf.AppendNum(1);
}
sBuf.Append(_L("\t"));
sBuf.Append(tempMessage->imobile);
sBuf.Append(_L("\t"));
TBuf<32> stemp;
CEikonEnv::Static()->ReadResource(stemp, R_FRMES_SENDING_LISTBOX_ERROR);
sBuf.Append(stemp);
cArray->AppendL(sBuf);
}
if(cArray->Count())
{
m_pListBox->HandleItemAdditionL();
}
}
bool CSendingMesContainer::InSending()
{
TInt nCurrentIndex = GetCurrentItemIndex();
MDesCArray* array = m_pListBox->Model()->ItemTextArray();
CDesCArray* cArray = ( CDesCArray* )array;
TBuf<64> sBuf;
TBuf<32> stemp;
sBuf.Copy(cArray->MdcaPoint(nCurrentIndex));
CEikonEnv::Static()->ReadResource(stemp, R_FRMES_SENDING_LISTBOX_ERROR);
if(sBuf.Right(4).Compare(stemp))
{
return false;
}
else
{
return true;
}
}
void CSendingMesContainer::DeleteMes()
{
CFrMesAppUi* pApp = (CFrMesAppUi*)CEikonEnv::Static()->AppUi();
CTextListBoxModel* model = m_pListBox->Model(); //Getting ListBox's Model
if (model->NumberOfItems() > 0) //Judging ListBox items is or not null
{
// CDesCArray* itemArray = STATIC_CAST(CDesCArray*, model->ItemTextArray());
TInt currentIndex = GetCurrentItemIndex(); //Getting selected item
pApp->m_pMessageDB->DelMessage(KMsvGlobalOutBoxIndexEntryId,currentIndex);
pApp->m_pMessageDB->GetMtmsEnginePoint()->DeleteMessageL(currentIndex);
}
}
void CSendingMesContainer::MoveMes()
{
CFrMesAppUi* pApp = (CFrMesAppUi*)CEikonEnv::Static()->AppUi();
CTextListBoxModel* model = m_pListBox->Model(); //Getting ListBox's Model
if (model->NumberOfItems() > 0) //Judging ListBox items is or not null
{
TInt currentIndex = GetCurrentItemIndex();
TBuf<16> sMobile;
TBuf<72> sMessage;
pApp->m_pMessageDB->GetMessage(KMsvGlobalOutBoxIndexEntryId,currentIndex,
sMobile,sMessage);
pApp->m_pMessageDB->AddMessageL(KMsvSentEntryId,sMobile,sMessage);
}
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -