📄 listboxappview.cpp
字号:
/* Copyright (c) 2008, Nokia. All rights reserved */
#include <eikdef.h>
#include <eikenv.h>
#include <Listbox.mbg>
#include "ListboxAppView.h"
#include "NDList.h"
CListboxAppView* CListboxAppView::NewL(const TRect& aRect)
{
CListboxAppView* self = NewLC(aRect);
CleanupStack::Pop(self);
return self;
}
CListboxAppView* CListboxAppView::NewLC(const TRect& aRect)
{
CListboxAppView* self = new (ELeave) CListboxAppView;
CleanupStack::PushL(self);
self->ConstructL(aRect);
return self;
}
void CListboxAppView::ConstructL(const TRect& aRect)
{
CreateWindowL();
CFbsBitmap* icon = LoadGraphicsL(1);
CFbsBitmap* iconSelect = LoadGraphicsL(0);
iList = new CNDList;
iList->ContructL(icon,iconSelect);
iArray = new(ELeave) CDesC16ArrayFlat(10);
iArray->AppendL(_L("hello"));
iArray->AppendL(_L("hello"));
iArray->AppendL(_L("hello"));
iList->SetItemArray(iArray);
SetRect(aRect);
ActivateL();
}
CListboxAppView::CListboxAppView()
{
// Add any construction code that can not leave here
}
CListboxAppView::~CListboxAppView()
{
// Add any destruction code here
if(iList)
{
delete iList;
iList = NULL;
}
if(iArray)
{
iArray->Reset();
delete iArray;
iArray = NULL;
}
}
void CListboxAppView::Draw(const TRect& /*aRect*/) const
{
// Clear the screen
CWindowGc& gc = SystemGc();
gc.Clear(Rect());
gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
gc.SetBrushColor(KRgbCyan);
const CFont* iFontTemp = iEikonEnv->LegendFont();
gc.UseFont(iFontTemp);
iList->Draw(gc);
}
CFbsBitmap* CListboxAppView::LoadGraphicsL(TInt aType)
{
TBuf<KMaxPath> pathAppMbm;
#ifdef __WINS__
pathAppMbm.Copy(_L("z:\\system\\apps\\Listbox\\Listbox.mbm"));
#else
TFileName appFullName;
appFullName = Application()->AppFullName();
TParsePtr parse(appFullName);
pathAppMbm.Copy(parse.DriveAndPath());
pathAppMbm.Append(_L("Listbox.mbm"));
#endif
switch(aType)
{
case 0:
return iEikonEnv->CreateBitmapL(pathAppMbm, EMbmListboxMarkoff);
case 1:
return iEikonEnv->CreateBitmapL(pathAppMbm, EMbmListboxMarkeditem);
default:
return NULL;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -