示例#1
0
void CMainMenuListContainer::AddItemL(TInt aBitmapId, TInt aMaskId,
                                      TInt aFirstLabelId, TInt aSecondLabelId)
{
    CArrayPtr<CGulIcon>* icons =
        iListBox->ItemDrawer()->FormattedCellData()->IconArray();
    if (!icons) {
        icons = new ( ELeave ) CAknIconArray(3);
        iListBox->ItemDrawer()->FormattedCellData()->SetIconArrayL(icons);
    }
    CleanupStack::PushL(icons);

    CFbsBitmap* bitmap;
    CFbsBitmap* mask;

    AknIconUtils::CreateIconL(bitmap, mask, iView->GetMbmName(),
                              aBitmapId, aMaskId);

    CleanupStack::PushL(bitmap);
    CleanupStack::PushL(mask);

    icons->AppendL(CGulIcon::NewL(bitmap, mask));

    CleanupStack::Pop(mask);
    CleanupStack::Pop(bitmap);
    CleanupStack::Pop(icons);

    HBufC* firstLabel = CEikonEnv::Static()->AllocReadResourceLC(aFirstLabelId);
    HBufC* secondLabel = CEikonEnv::Static()->AllocReadResourceLC(aSecondLabelId);

    HBufC* itemText = HBufC::NewLC(firstLabel->Length() +
                                   secondLabel->Length() + 16);

    itemText->Des().Format(KItem(), (icons->Count() - 1), firstLabel, secondLabel);

    CDesCArray* itemArray =
        static_cast<CDesC16ArrayFlat*>(iListBox->Model()->ItemTextArray());

    itemArray->AppendL(*itemText);

    CleanupStack::PopAndDestroy(itemText);
    CleanupStack::PopAndDestroy(secondLabel);
    CleanupStack::PopAndDestroy(firstLabel);

    iListBox->HandleItemAdditionL();
}
// -----------------------------------------------------------------------------
// CUpnpObjectBean::AttachObjectElL
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
TXmlEngElement CUpnpObjectBean::AttachObjectElL(TXmlEngElement aElement)
{
    TXmlEngElement object;

    // check if the object is a container
    if( ObjClass().Find( KContainerClass8 ) == 0 )
    {   // container
        object = aElement.AddNewElementSameNsL( KContainer() );
    }
    else
    {   // item
        object = aElement.AddNewElementSameNsL( KItem() );
    }

    // add required properties
    AttachRequiredPropertiesL(object);

    return object;
}