Symbian CAknGrid的应用
2010-05-31 20:14:00 来源:WEB开发网在Symbian下我们经常会有这样的需求,把我们的UI设计成九封格样子.
今天我们来看看9封格的UI是如何实现的.
实现效果如下图:
让我们进入正题来看是如何实现的.
//创建初始化一些句柄
void CUserGridContainer::ConstructL(const TRect&aRect)
{
CreateWindowL();
iGrid = new(ELeave ) CAknGrid;
iGrid->SetContainerWindowL( *this );
iGridModel =new( ELeave ) CAknGridM();
iGrid->SetModel( iGridModel );
iGrid->ConstructL( this, EAknListBoxSelectionGrid);
LoadList();
iGrid->SetListBoxObserver(this);
DrawGrid(aRect);
iGrid->SetCurrentItemIndex(4);
SetRect(aRect);
ActivateL();
}
void CUserGridContainer::LoadList()
{
CArrayPtr
//加载图标
CleanupStack::PushL(icons);
icons->AppendL(iEikonEnv->CreateIconL(KDoubleListBoxmbm);
CleanupStack::Pop(icons);
iGrid->ItemDrawer()->FormattedCellData()->SetIconArray(icons);
//加载文字
CDesCArray*array = new ( ELeave )CDesCArrayFlat(icons->Count());
CleanupStack::PushL(array);
array->AppendL(_L("0 Item1"));
array->AppendL(_L("1 Item2"));
array->AppendL(_L("2 Item3"));
array->AppendL(_L("3 Item4"));
array->AppendL(_L("4 Item5"));
array->AppendL(_L("5 Item6"));
array->AppendL(_L("6 Item7"));
array->AppendL(_L("7 Item8"));
CleanupStack::Pop();
iGrid->Model()->SetItemTextArray(array);
}
//绘制DrawGrid.在这里需要根据指定的区域大小来绘制.
更多精彩
赞助商链接