Code snippet for creating column listbox on Symbian/UIQ

类别:软件工程 点击:0 评论:0 推荐:

void CMediaStreamListView::CreateColumnListBox(const TRect &aRect/*,TInetAddr& aAddress*/,TFileName aMbmFilePath)
{
 iColumnListBox=new (ELeave)CEikColumnListBox;
 iColumnListBox->ConstructL(this,CEikColumnListBox::ENoExtendedSelection|CEikColumnListBox::ENoFirstLetterMatching);
 
 
 iColumnListBox->SetRect(aRect);

 iColumnListBox->SetListBoxObserver(this);
    iColumnListBox->SetContainerWindowL(*this);
 
 iColumnListBox->CreateScrollBarFrameL(ETrue);

 iColumnListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOn,CEikScrollBarFrame::EAuto);

 const TUint KCol0=0;
 const TUint KCol1=1;
 TInt w=Rect().Width();
 
 CColumnListBoxData * colData=iColumnListBox->ItemDrawer()->ColumnData();
 CleanupStack::PushL(colData);
 
 //set column width
    colData->SetColumnWidthPixelL(KCol0,(w*1)/15);
 colData->SetColumnWidthPixelL(KCol1,(2*w));
 
 //set column alignment
    colData->SetColumnAlignmentL(KCol0,CGraphicsContext::ECenter);
 colData->SetColumnAlignmentL(KCol1,CGraphicsContext::ELeft);

 iColumnListBox->SetFocus(ETrue);

 CleanupStack::Pop();

 iConList=new  (ELeave)CArrayPtrFlat<CGulIcon>(10);
 
 iConList->AppendL( iEikonEnv->CreateIconL(   aMbmFilePath,
                                                 EMbmVideoimagesFolder,
                                                 EMbmVideoimagesFolder_mask) );
    iConList->AppendL( iEikonEnv->CreateIconL(   aMbmFilePath,
                                                 EMbmVideoimagesVideo_doc,
                                                 EMbmVideoimagesVideo_doc_mask) );

 iColumnListBox->ItemDrawer()->ColumnData()->SetIconArray( iConList );
   
    iColumnListBox->ItemDrawer()->ColumnData()->SetGraphicsColumnL(0,ETrue); 
 
 
 iListBoxItems=new CDesC16ArrayFlat(10);


 CTextListBoxModel * model=iColumnListBox->Model();

 model->SetItemTextArray(iListBoxItems);
 model->SetOwnershipType(ELbmOwnsItemArray);

    iColumnListBox->View()->CalcBottomItemIndex();
    iColumnListBox->HandleItemAdditionL();
    iColumnListBox->MakeVisible(ETrue);
   SetComponentsToInheritVisibility();
  

    iListBoxItems->Reset();

    iColumnListBox->HandleItemAdditionL();

    iColumnListBox->SetCurrentItemIndexAndDraw(0);

}

本文地址:http://com.8s8s.com/it/it33149.htm