📄 receivemescontainer.cpp
字号:
/*
* ============================================================================
* Name : CReceiveMesContainer from CCoeControl, MCoeControlObserver
* Part of : ReceiveMes
* 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> // for CColumnListBoxData
#include <FrMes.rsg>
#include "FrMes.hrh"
#include "ReceiveMesContainer.h"
#include "FrMesAppUi.h"
#include "akniconarray.h"
#include "MtmsEngine.h"
#include "msvids.h"
#include "MessageDB.h"
#include <aknquerydialog.h>
// ================= MEMBER FUNCTIONS =======================
// C++ default constructor can NOT contain any code, that
// might leave.
//
CReceiveMesContainer::CReceiveMesContainer()
{
m_pListBox = NULL;
m_pListBoxArray = NULL;
}
// EPOC default constructor can leave.
void CReceiveMesContainer::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 );
LoadGraphicsL();
AddDataL();
SetRect(aRect);
ActivateL();
}
// Destructor
CReceiveMesContainer::~CReceiveMesContainer()
{
if(m_pListBox)
{
delete m_pListBox;
m_pListBox = NULL;
}
if(m_pListBoxArray)
{
delete m_pListBoxArray;
m_pListBoxArray = NULL;
}
}
// ---------------------------------------------------------
// CReceiveMesContainer::FocusTo(TInt aCommand)
// Change foccused control.
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CReceiveMesContainer::FocusTo(TInt aCommand)
{
}
// ---------------------------------------------------------
// CReceiveMesContainer::SizeChanged()
// Called by framework when the view size is changed
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CReceiveMesContainer::SizeChanged()
{
if (m_pListBox)
{
m_pListBox->SetRect(Rect());
}
}
// ---------------------------------------------------------
// CReceiveMesContainer::CountComponentControls() const
// (other items were commented in a header).
// ---------------------------------------------------------
//
TInt CReceiveMesContainer::CountComponentControls() const
{
return 1; // return nbr of controls inside this container
}
// ---------------------------------------------------------
// CReceiveMesContainer::ComponentControl(TInt aIndex) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
CCoeControl* CReceiveMesContainer::ComponentControl(TInt aIndex) const
{
switch(aIndex)
{
case 0:
return m_pListBox;
default:
return NULL;
}
}
// ---------------------------------------------------------
// CReceiveMesContainer::Draw(const TRect& aRect) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CReceiveMesContainer::Draw(const TRect& aRect) const
{
CWindowGc& gc = SystemGc();
gc.SetPenStyle(CGraphicsContext::ENullPen);
gc.SetBrushColor(KRgbGray);
gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
gc.DrawRect(aRect);
}
// ---------------------------------------------------------
// CReceiveMesContainer::OfferKeyEventL(...)
// Notify key events to editors.
// (other items were commented in a header).
// ---------------------------------------------------------
//
TKeyResponse CReceiveMesContainer::OfferKeyEventL(
const TKeyEvent& aKeyEvent, TEventCode aType)
{
if (m_pListBox)
return m_pListBox->OfferKeyEventL (aKeyEvent, aType);
else
return EKeyWasNotConsumed;
}
// ---------------------------------------------------------
// CReceiveMesContainer::HandleControlEventL(
// CCoeControl* aControl,TCoeEvent aEventType)
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CReceiveMesContainer::HandleControlEventL(
CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
{
}
TInt CReceiveMesContainer::GetCurrentItemIndex()
{
return m_pListBox->CurrentItemIndex();
}
void CReceiveMesContainer::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 CReceiveMesContainer::AddDataL()
{
//modify by wzg 08_07_15
CFrMesAppUi* pApp = (CFrMesAppUi*)CEikonEnv::Static()->AppUi();
CArrayFixFlat<TInt32>* tempArray = pApp->m_pMessageDB->
GetMessageArray(KMsvGlobalInBoxIndexEntryId);
if(!tempArray->Count())
{
pApp->m_pMessageDB->ReadMessageToArrayL(KMsvGlobalInBoxIndexEntryId);
}
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"));
sBuf.Append(tempMessage->imessage);
cArray->AppendL(sBuf);
}
if(cArray->Count())
{
m_pListBox->HandleItemAdditionL();
}
}
void CReceiveMesContainer::DeleteMes()
{
CFrMesAppUi* pApp = (CFrMesAppUi*)CEikonEnv::Static()->AppUi();
CAknQueryDialog* pdialog = CAknQueryDialog::NewL( CAknQueryDialog::ENoTone );
TBool aResult=pdialog->ExecuteLD( R_QTN_DELMES_DIALOG );
if (aResult)
{
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(KMsvGlobalInBoxIndexEntryId,currentIndex);
pApp->m_pMessageDB->GetMtmsEnginePoint()->DeleteMessageL(currentIndex);
}
}
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -