📄 inboxdraftssentcontainer.cpp
字号:
/*
* ============================================================================
* Name : CInBoxDraftsSentContainer from CCoeControl, MCoeControlObserver
* Part of : Sms
* Copyright (c) 2003 Nokia. All rights reserved.
* ============================================================================
*/
// INCLUDE FILES
#include <HelperGenius.rsg>
#include "HelperGenius.hrh"
#include "InBoxDraftsSentContainer.h"
#include <aknlists.h>
#include "HelperGeniusAppUi.h"
#include <EikEnv.h>
#include <Helpergenius.mbg>
#include <fbs.h>
#include <AknUtils.h>
#include <stringloader.h>
#include <barsread.h>
#include <gulicon.h>
#include <AknIconArray.h>
#include <EIKCLB.H>
#include <eikfrlb.h>
#include <eikslb.h>
#define DELPTR(p) if(p!=NULL){ delete p;p=NULL;}
// ================= MEMBER SmsS =======================
// C++ default constructor can NOT contain any code, that
// might leave.
//
CInBoxDraftsSentContainer::CInBoxDraftsSentContainer()
{
m_pListBox = NULL;
m_pBitmap = NULL;
m_pListBoxArray = NULL;
}
// EPOC default constructor can leave.
void CInBoxDraftsSentContainer::ConstructL(const TRect& aRect)
{
CreateWindowL();
//设置背景图片
SetBackgroupL( );
//创建列表
CreateListL(aRect );
//设置列表图标
SetupListIconsL();
//添加信息到列表
//AddInfoToList();
iIndex = 0;
SetRect(aRect);
ActivateL();
//来自网上
// LIT( KListItemFormat, "0\tItem %d" );
// void CFMOForSymbianMailList::InitializeControlsL()
// {
// iListBox = new ( ELeave ) CAknDoubleGraphicStyleListBox;
// iListBox->SetContainerWindowL( *this );
// {
// TResourceReader reader;
// iEikonEnv->CreateResourceReaderLC( reader, R_FMOFOR_SYMBIAN_MAIL_LIST_LIST_BOX );
// iListBox->ConstructFromResourceL( reader );
// CleanupStack::PopAndDestroy(); // reader internal state
// }
// // the listbox owns the items in the list and will free them
// iListBox->Model()->SetOwnershipType( ELbmOwnsItemArray );
//
// TBuf<20> itemText;
//
// CDesCArray* itemArray = new ( ELeave ) CDesCArrayFlat(4);
//
// for( TInt i = 1; i < 5; ++i )
// {
// itemText.Format( KListItemFormat(), i );
// itemArray->AppendL( itemText );
// }
//
// iListBox->Model()->SetItemTextArray( itemArray );
// iListBox->Model()->SetOwnershipType( ELbmOwnsItemArray );
// iListBox->HandleItemAdditionL();
// // setup the icon array so graphics-style boxes work
// SetupListBoxIconsL();
//
//
// // add list items
//
// iListBox->SetFocus( ETrue );
// iFocusControl = iListBox;
//
// }
}
// Destructor
CInBoxDraftsSentContainer::~CInBoxDraftsSentContainer()
{
DELPTR(m_pListBox);
DELPTR(m_pBitmap);
DELPTR(m_pListBoxArray);
}
// ---------------------------------------------------------
// CInBoxDraftsSentContainer::FocusTo(TInt aCommand)
// Change foccused control.
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CInBoxDraftsSentContainer::FocusTo(TInt aCommand)
{
}
// ---------------------------------------------------------
// CInBoxDraftsSentContainer::SizeChanged()
// Called by framework when the view size is changed
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CInBoxDraftsSentContainer::SizeChanged()
{
if(m_pListBox)
{
m_pListBox->SetRect(Rect( ) );
}
}
// ---------------------------------------------------------
// CInBoxDraftsSentContainer::CountComponentControls() const
// (other items were commented in a header).
// ---------------------------------------------------------
//
TInt CInBoxDraftsSentContainer::CountComponentControls() const
{
return 1; // return nbr of controls inside this container
}
// ---------------------------------------------------------
// CInBoxDraftsSentContainer::ComponentControl(TInt aIndex) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
CCoeControl* CInBoxDraftsSentContainer::ComponentControl(TInt aIndex) const
{
return m_pListBox;
}
// ---------------------------------------------------------
// CInBoxDraftsSentContainer::Draw(const TRect& aRect) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CInBoxDraftsSentContainer::Draw(const TRect& aRect) const
{
CWindowGc& gc = SystemGc();
/******添加背景图片*******************************************/
gc.Clear(aRect);
TPoint topLeft(0,0);
// gc.DrawBitmap(TRect(topLeft,TSize(176,208)),m_pBitmap);
gc.BitBlt(topLeft,m_pBitmap,TRect(topLeft,TSize(176,208)));
}
// ---------------------------------------------------------
// CInBoxDraftsSentContainer::OfferKeyEventL(...)
// Notify key events to editors.
// (other items were commented in a header).
// ---------------------------------------------------------
//
TKeyResponse CInBoxDraftsSentContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
{
if(NULL != m_pListBox)
{
if((aType == EEventKey) && (aKeyEvent.iCode == EKeyDownArrow))
{
if(iIndex == m_pListBoxArray->Count()-1)
iIndex = 0;
else
++iIndex;
return m_pListBox->OfferKeyEventL(aKeyEvent, aType);
}
else if((aType == EEventKey) && (aKeyEvent.iCode == EKeyUpArrow))
{
if(iIndex == 0)
iIndex = m_pListBoxArray->Count()-1;
else
--iIndex;
return m_pListBox->OfferKeyEventL(aKeyEvent, aType);
}
return EKeyWasConsumed;
}
return EKeyWasNotConsumed;
}
// ---------------------------------------------------------
// CInBoxDraftsSentContainer::HandleControlEventL(
// CCoeControl* aControl,TCoeEvent aEventType)
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CInBoxDraftsSentContainer::HandleControlEventL(
CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
{
}
void CInBoxDraftsSentContainer::AddInfoToList( TInt anIndex, TDesC& aszName, TDesC& aszContent )
{
TBuf<KMaxPath> szTemp;
szTemp.AppendNum(anIndex);
szTemp.Append(_L("\t"));
szTemp.Append(aszName);
szTemp.Append(_L("\t"));
szTemp.Append(aszContent);
m_pListBoxArray->AppendL(szTemp);
m_pListBox->HandleItemAdditionL();
m_pListBox->SetCurrentItemIndexAndDraw(0);
}
TInt CInBoxDraftsSentContainer::GetIndex()
{
return iIndex;
}
CDesCArrayFlat* CInBoxDraftsSentContainer::GetListBoxArray()
{
return m_pListBoxArray;
}
void CInBoxDraftsSentContainer::SetupListIconsL( )
{
HBufC* iconFileName;
iconFileName = StringLoader::LoadLC( R_ICON_FILE_NAME );
CArrayPtr<CGulIcon>* icons = new(ELeave) CAknIconArray(6); ////??????????? 不用释放吗?
CleanupStack::PushL(icons);
icons->AppendL(iEikonEnv->CreateIconL(*iconFileName,EMbmHelpergeniusDraft,EMbmHelpergeniusDraft_mask));
icons->AppendL(iEikonEnv->CreateIconL(*iconFileName,EMbmHelpergeniusReceivesms,EMbmHelpergeniusReceivesms_mask));
icons->AppendL(iEikonEnv->CreateIconL(*iconFileName,EMbmHelpergeniusSent,EMbmHelpergeniusSent_mask));
icons->AppendL(iEikonEnv->CreateIconL(*iconFileName,EMbmHelpergeniusUnreadicon,EMbmHelpergeniusUnreadicon_mask));
icons->AppendL(iEikonEnv->CreateIconL(*iconFileName,EMbmHelpergeniusReadicon,EMbmHelpergeniusReadicon_mask));
// icons->AppendL(iEikonEnv->CreateIconL(*iconFileName,EMbmHelpergeniusUnreadicon,EMbmHelpergeniusUnreadicon_mask));
CleanupStack::Pop(icons);
CleanupStack::PopAndDestroy(iconFileName);
m_pListBox->ItemDrawer()->ColumnData()->SetIconArray(icons);
//m_pListBox->ItemDrawer()->FormattedCellData()->SetIconArray(icons);
}
void CInBoxDraftsSentContainer::SetBackgroupL( )
{
m_pBitmap = new (ELeave) CFbsBitmap;
TBuf<KMaxPath> pathMbm;
#ifdef __WINS__
pathMbm.Copy(_L("z:\\system\\apps\\HelperGenius\\HelperGenius.mbm"));
#else
CHelperGeniusAppUi* pApp = (CHelperGeniusAppUi*)CEikonEnv::Static()->AppUi();
pApp->GetAppPath(pathMbm);
pathMbm.Append(_L("HelperGenius.mbm"));
#endif
User::LeaveIfError(CompleteWithAppPath(pathMbm));
User::LeaveIfError(m_pBitmap->Load(pathMbm,EMbmHelpergeniusHelpergenius_icon_17));
}
void CInBoxDraftsSentContainer::CreateListL( const TRect& aRect )
{
m_pListBox = new(ELeave) CAknDoubleGraphicStyleListBox;
CleanupStack::PushL(m_pListBox);
m_pListBox->ConstructL(this,EAknListBoxMarkableList | EAknListBoxMultiselectionList);
m_pListBox->SetContainerWindowL(*this);
m_pListBox->SetRect(aRect);
m_pListBox->CreateScrollBarFrameL(ETrue);
m_pListBox->ScrollBarFrame( )->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EAuto);
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->ActivateL();
m_pListBox->SetFocus( ETrue );
}
TInt CInBoxDraftsSentContainer::GetCurrentIndex()
{
return m_pListBox->CurrentItemIndex();
}
void CInBoxDraftsSentContainer::DeleteListBox(TInt aIndex)
{
m_pListBoxArray->Delete(aIndex);
m_pListBox->HandleItemRemovalL();
}
// void CInBoxDraftsSentContainer::SizeChanged()
// {
// if (m_pListBox)
// {
//
// CAknDoubleGraphicStyleListBox* aknListBox = STATIC_CAST(CAknDoubleGraphicStyleListBox*,
// m_pListBox);
// // AknFind::HandleFixedFindSizeChanged(this, aknListBox, m_pSearchBox);
// m_pListBox->SetRect(Rect()); // Sets rectangle of lstbox.
// }
// }
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -