Join Now
Quality Rating:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

This page was last modified 11:31, 29 November 2007.

Branding PopupList

From Forum Nokia Wiki

Following code illustrates how to use Popup lists for displaying data along with the Icon

With this example the Popup list is constructed as CAknSinglePopupMenuStyleListBox, but you could also use Other types of Popuplists. CAknPopupList Takes an existing listbox control and puts it into a popup frame together with an optional title.

Note: The format for the item text string depends on the Popup list type. If you change the Popup list type you also need to modify the item text string format accordingly.

#include <aknlists.h> 
#include <eikimage.h>
void CBrandingPopup::ShowPopupListL()
    {
    // Create CEikTextListBox instance, list
    CEikTextListBox* list = new( ELeave ) CAknSinglePopupMenuStyleListBox;
    // Push list pointer to CleanupStack.
    CleanupStack::PushL( list );
    // Create CAknPopupList instance, popupList
    CAknPopupList* popupList = CAknPopupList::NewL( list,
                                                    R_AVKON_SOFTKEYS_SELECT_CANCEL,
                                                    AknPopupLayouts::EMenuWindow );
    // Push popupList pointer to CleanupStack.
    CleanupStack::PushL(popupList);
    // Initialize listbox.
    list->ConstructL( popupList, CEikListBox::ELeftDownInViewRect );
    list->CreateScrollBarFrameL( ETrue );
    list->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff,
                                                     CEikScrollBarFrame::EAuto );
    CDesCArrayFlat* iListArray = new (ELeave) CDesCArrayFlat(2);
    CleanupStack::PushL( iListArray);
    TBuf<50> name;
    name.Copy(_L("PopupList"));
    TPtrC ptr = name.Mid(0);
    iListArray->AppendL(ptr);
    CleanupStack::Pop(); 
    HBufC* text = StringLoader::LoadLC( R_TEXT_EXAMPLE );  
    TBuf <30> Kyte;
    Kyte.Copy(*text);
    CleanupStack::Pop(text);
    popupList->SetTitleL(Kyte);
    CEikImage* image = new (ELeave) CEikImage();            
    CleanupStack::PushL(image);
    CFbsBitmap* bitmap ;
    CFbsBitmap* mask ;
    TFileName iconfile(_L("z:\\resource\\apps\\Branding.mif"));
    //Load the required icon for your popup list
    AknIconUtils::CreateIconL(bitmap, mask, iconfile, EMbmBrand, EMbmBrand+1);  		
    TSize iconSize(20,20);
    User::LeaveIfError(AknIconUtils::SetSize(bitmap, iconSize, EAspectRatioNotPreserved));
    User::LeaveIfError(AknIconUtils::SetSize(mask, iconSize, EAspectRatioNotPreserved));
    CleanupStack::PushL(bitmap);
    CleanupStack::PushL(mask);
    image->SetPicture(bitmap,mask);
    image->SetBitmap(bitmap);
    image->SetMask(mask);
    popupList->Heading()->SetHeaderImageL(image);
    CleanupStack::Pop(2); // mask and bitmap
    CleanupStack::PopAndDestroy();  // image...mask and bitmap are also deleted
    // when image is deleted. 
    // Set listitems.
    CTextListBoxModel* model = list->Model();
    model->SetItemTextArray( iListArray );
    model->SetOwnershipType( ELbmOwnsItemArray );
    // Show popup list and then show return value.
    TBool popupOk = popupList->ExecuteLD();
    if(popupOk)
    {
    TInt index=list->CurrentItemIndex();
    }
    else
    {
    }
    CleanupStack::Pop();
    CleanupStack::PopAndDestroy();
}
Related Discussions
Thread Thread Starter Forum Replies Last Post
Application access set to not allowed testing APDUMIDlet ivalladt Mobile Java Tools & SDKs 12 2007-08-29 08:57
求助:关于CAknPopupList中的对齐 fyz Symbian 2 2005-06-08 08:15
product code for nokia 6233 grey-falcon General Discussion 0 2007-05-15 16:01
MMListEmpty error, PC Suite 6.7 bbwalter PC Suite API and PC Connectivity SDK 9 2008-02-12 17:48
Searching aknGMSstylegrid.cpp ArneH Symbian User Interface 4 2004-08-06 08:26
 
Powered by MediaWiki
     
     RDF Facets:
     
     
     qfnZtopicQUqfnTopicZseriesE5f60Q
     qfnZtypeQUqfnTypeZCommunityContentQ
     qfnZtypeQUqfnTypeZWebpageQ
     qfnZtypeQUqfnTypeZWikiContentQ
     qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX