📄 bookmescontainer.cpp
字号:
/*
* ============================================================================
* Name : CBookMesContainer from CCoeControl, MCoeControlObserver
* Part of : BookMes
* 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 "BookMesContainer.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.
//
CBookMesContainer::CBookMesContainer()
{
m_pListBox = NULL;
m_pListBoxArray = NULL;
}
// EPOC default constructor can leave.
void CBookMesContainer::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
CBookMesContainer::~CBookMesContainer()
{
if(m_pListBox)
{
delete m_pListBox;
m_pListBox = NULL;
}
if(m_pListBoxArray)
{
delete m_pListBoxArray;
m_pListBoxArray = NULL;
}
}
// ---------------------------------------------------------
// CBookMesContainer::FocusTo(TInt aCommand)
// Change foccused control.
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CBookMesContainer::FocusTo(TInt aCommand)
{
}
// ---------------------------------------------------------
// CBookMesContainer::SizeChanged()
// Called by framework when the view size is changed
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CBookMesContainer::SizeChanged()
{
if (m_pListBox)
{
m_pListBox->SetRect(Rect());
}
}
// ---------------------------------------------------------
// CBookMesContainer::CountComponentControls() const
// (other items were commented in a header).
// ---------------------------------------------------------
//
TInt CBookMesContainer::CountComponentControls() const
{
return 1; // return nbr of controls inside this container
}
// ---------------------------------------------------------
// CBookMesContainer::ComponentControl(TInt aIndex) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
CCoeControl* CBookMesContainer::ComponentControl(TInt aIndex) const
{
switch(aIndex)
{
case 0:
return m_pListBox;
default:
return NULL;
}
}
// ---------------------------------------------------------
// CBookMesContainer::Draw(const TRect& aRect) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CBookMesContainer::Draw(const TRect& aRect) const
{
CWindowGc& gc = SystemGc();
gc.SetPenStyle(CGraphicsContext::ENullPen);
gc.SetBrushColor(KRgbGray);
gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
gc.DrawRect(aRect);
}
// ---------------------------------------------------------
// CBookMesContainer::OfferKeyEventL(...)
// Notify key events to editors.
// (other items were commented in a header).
// ---------------------------------------------------------
//
TKeyResponse CBookMesContainer::OfferKeyEventL(
const TKeyEvent& aKeyEvent, TEventCode aType)
{
if (m_pListBox)
return m_pListBox->OfferKeyEventL (aKeyEvent, aType);
else
return EKeyWasNotConsumed;
}
// ---------------------------------------------------------
// CBookMesContainer::HandleControlEventL(
// CCoeControl* aControl,TCoeEvent aEventType)
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CBookMesContainer::HandleControlEventL(
CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
{
}
void CBookMesContainer::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 CBookMesContainer::AddDataL()
{
//modify by wzg 08_07_13
CFrMesAppUi* pApp = (CFrMesAppUi*)CEikonEnv::Static()->AppUi();
CArrayFixFlat<TInt32>* tempArray = pApp->m_pMessageDB->
GetMessageArray(KMsvDraftEntryId);
if(!tempArray->Count())
{
pApp->m_pMessageDB->ReadMessageToArrayL(KMsvDraftEntryId);
}
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();
}
}
TInt CBookMesContainer::GetCurrentItemIndex()
{
return m_pListBox->CurrentItemIndex();
}
void CBookMesContainer::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(KMsvDraftEntryId,currentIndex);
pApp->m_pMessageDB->GetMtmsEnginePoint()->DeleteMessageL(currentIndex);
}
}
}
// void CBookMesContainer::DisplayList()
// {
// CFrMesAppUi* pApp = (CFrMesAppUi*)CEikonEnv::Static()->AppUi();
// TInt aCount = pApp->m_pDB->iArray->Count();
// m_pListBoxArray->Reset();
// if(aCount>0)
// {
// for(int i=0;i<aCount;i++)
// {
// TBuf<16> aName;
// TBuf<16> aCode;
// pApp->m_pDB->GetItem(i,aName,aCode);
//
// TBuf<32> aText;
// TBuf<32> sText;
// CEikonEnv::Static()->ReadResource(aText, R_QTN_FRMES_LISTBOX_NAME);
// CEikonEnv::Static()->ReadResource(sText, R_QTN_FRMES_LISTBOX_TEL);
// aText.Append(aName);
// sText.Append(aCode);
// AddInfoToList(i+1, aText, sText);
// }
// m_pListBox->SetCurrentItemIndex(0);
// }
// }
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -