×

Discussion Board

Results 1 to 11 of 11
  1. #1
    Regular Contributor
    Join Date
    Aug 2008
    Posts
    413

    How to add my own icon to List Box element??

    hi all,

    i am creating Listbox using following code...

    Code:
    iListBox = new (ELeave) CAknDoubleLargeStyleListBox();
    
            // Construct listbox 
    
            iListBox->ConstructL( this, EAknListBoxSelectionList | EAknListBoxLoopScrolling );
    
            iListBox->SetContainerWindowL( *this );
    
            // Set scrollbars
            
            iListBox->CreateScrollBarFrameL( ETrue );
    
            iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOn, CEikScrollBarFrame::EAuto );   
        
            // Create listbox item array
    
            iListBoxItems = new (ELeave) CDesCArrayFlat(6);
            
            // Create listbox items
    
            iListBoxItems->AppendL( _L("0\tSales Order\t") );
            iListBoxItems->AppendL( _L("1\tPayment Collection\t") );
            iListBoxItems->AppendL( _L("2\tOrder Status\t") );
            iListBoxItems->AppendL( _L("3\tStock Status\t") );
            iListBoxItems->AppendL( _L("4\tDealer Outstanding\t") );
            iListBoxItems->AppendL( _L("5\tAbout\t") );
    
            // Add items to listbox
    
            iListBox->Model()->SetItemTextArray( iListBoxItems );
    
            // Listbox deletes the item array
    
            iListBox->Model()->SetOwnershipType( ELbmOwnsItemArray );
            iListBox->HandleItemAdditionL( );
            
            //To get event in HandleListBoxEventL()
            //Do not forgot to add it..........
            iListBox->SetListBoxObserver(this);
            // Add icons to listbox
    
            AddListboxIconsL();
    
            // Activate Listbox
            iListBox->SetRect( Rect() );
            iListBox->ActivateL();
    
            
        
            SetRect(aRect);
            ActivateL();
    And i have taken a seprate function for adding Icons ie AddListboxIconsL() which is as follows..
    Code:
     void CmSales_LoginMenuViewContainer::AddListboxIconsL()
    
               {
    
               CArrayPtr<CGulIcon>* iconArray = new( ELeave ) CAknIconArray( 1 );
               CleanupStack::PushL( iconArray );
    
               
    
               CFbsBitmap* addressIcon = NULL;
               CFbsBitmap* addressIconMask = NULL;
               CFbsBitmap* emailIcon = NULL;
               CFbsBitmap* emailIconMask = NULL;
               CFbsBitmap* faxIcon = NULL;
               CFbsBitmap* faxIconMask = NULL;
               
               CFbsBitmap* homeIcon = NULL;
               CFbsBitmap* homeIconMask = NULL;
               CFbsBitmap* mobileIcon = NULL;
               CFbsBitmap* mobileIconMask = NULL;
               CFbsBitmap* phoneIcon = NULL;
               CFbsBitmap* phoneIconMask = NULL;
               
    
               
    
               AknIconUtils::CreateIconLC( addressIcon,
    
                                          addressIconMask, 
    
                                          KAvkonBitmapFile, 
    
                                          EMbmAvkonQgn_prop_nrtyp_address, 
    
                                          EMbmAvkonQgn_prop_nrtyp_address_mask );
    
                                          
    
               CGulIcon* addressListIcon = CGulIcon::NewL( addressIcon, addressIconMask );
               CleanupStack::Pop( 2 ); // addressIcon, addressIconMask
               CleanupStack::PushL( addressListIcon );
               iconArray->AppendL( addressListIcon );    			
    
                                          
    
                                          
    
               AknIconUtils::CreateIconLC( emailIcon, 
    
                                          emailIconMask, 
    
                                          KAvkonBitmapFile, 
    
                                          EMbmAvkonQgn_prop_nrtyp_email, 
    
                                          EMbmAvkonQgn_prop_nrtyp_email_mask );
    
                                          
    
               CGulIcon* emailListIcon = CGulIcon::NewL( emailIcon, emailIconMask );
    
               CleanupStack::Pop( 2 ); // emailIcon, emailIconMask
    
               CleanupStack::PushL( emailListIcon );
    
               iconArray->AppendL( emailListIcon );
    
                                          
    
                                          
    
               AknIconUtils::CreateIconLC( faxIcon, 
    
                                          faxIconMask, 
    
                                          KAvkonBitmapFile, 
    
                                          EMbmAvkonQgn_prop_nrtyp_fax, 
    
                                          EMbmAvkonQgn_prop_nrtyp_fax_mask );    
    
                                 
    
               CGulIcon* faxListIcon = CGulIcon::NewL( faxIcon, faxIconMask );
    
               CleanupStack::Pop( 2 ); // faxIcon, faxIconMask   
    
               CleanupStack::PushL( faxListIcon );
    
               iconArray->AppendL( faxListIcon );
    
    
               AknIconUtils::CreateIconLC( homeIcon,
    
                                             homeIconMask, 
    
                                             KAvkonBitmapFile, 
    
                                             EMbmAvkonQgn_prop_nrtyp_home, 
    
                                             EMbmAvkonQgn_prop_nrtyp_home_mask );
    
                                             
    
                  CGulIcon* homeListIcon = CGulIcon::NewL( homeIcon, homeIconMask );
                  CleanupStack::Pop( 2 ); // addressIcon, addressIconMask
                  CleanupStack::PushL( homeListIcon );
                  iconArray->AppendL( homeListIcon );    			
    
                  
                  AknIconUtils::CreateIconLC( mobileIcon,
    
                                                mobileIconMask, 
    
                                                KAvkonBitmapFile, 
    
                                                EMbmAvkonQgn_prop_nrtyp_mobile, 
    
                                            	EMbmAvkonQgn_prop_nrtyp_mobile_mask );
    
                                                
    
                     CGulIcon* mobileListIcon = CGulIcon::NewL( mobileIcon, mobileIconMask );
                     CleanupStack::Pop( 2 ); // addressIcon, addressIconMask
                     CleanupStack::PushL( mobileListIcon );
                     iconArray->AppendL( mobileListIcon );    			
    
                     
                     AknIconUtils::CreateIconLC( phoneIcon,
    
                                                   phoneIconMask, 
    
                                                   KAvkonBitmapFile, 
    
                                               	EMbmAvkonQgn_prop_nrtyp_phone, 
    
                                               	EMbmAvkonQgn_prop_nrtyp_phone_mask );
    
                                                   
    
                        CGulIcon* phoneListIcon = CGulIcon::NewL( phoneIcon, phoneIconMask );
                        CleanupStack::Pop( 2 ); // addressIcon, addressIconMask
                        CleanupStack::PushL( phoneListIcon );
                        iconArray->AppendL( phoneListIcon );    			
                 
               iListBox->ItemDrawer()->ColumnData()->SetIconArray( iconArray );
    
               // faxListIcon, emailListIcon, addressListIcon, iconArray    
    
               CleanupStack::Pop( 7 );
    
               iListBox->HandleItemAdditionL();
    these r standard symbian icons.Now i want to add my own icons instead of this icons.How to do it??

    Rohanwaugh
    Last edited by ltomuta; 2008-11-29 at 12:38.

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,674

    Re: How to add my own icon to List Box element??

    As you can see, icons are created via putting CFbsBitmap objects (so bitmaps) into CGulIcon-s, collecting them in an array, then passing the array to the listbox. You can freely append your own icons to the same array.

  3. #3
    Regular Contributor
    Join Date
    Aug 2008
    Posts
    413

    Re: How to add my own icon to List Box element??

    hi ,

    Thanks for the reply..I have some questions to be asked..

    1.In the code snippet i had pasted in the last reply,what changes i need to do to add my own icons??

    2.Or i have to discard that application and have to create a new application and follow some different approch??

    3.I have images to be set as icons but they are in JPEG format.JPEG images will do in Symbian??

    4.Where i should store these images??

    Thanks in advance..

    ROhanwaugh..

  4. #4
    Super Contributor
    Join Date
    Mar 2004
    Location
    Czech Republic
    Posts
    2,037

    Re: How to add my own icon to List Box element??

    Hi,

    1. Ideally you should create the mbm file with your icons and load it from this file - you can check the wiki how such file is created and how to load the icon from it - for each icon you will need also black&white mask. If you are able to provide the icon in vector svg format you will not need to create the mask explicitly. Check classes and methods CGulIcon, CFbsBitmap, CEikonEnv::CreateIconL() and AknIconUtils::CreateIconLC() in SDK help. Check also wiki for examples how to use listboxes.

    2. No need to discard - just modify the existing code.

    3. JPEG format is not so good, because you have to make the file format conversion, which will be better for you to avoid + you will have the problem with the icon mask. Use approach mentioned in 1/.

    4. As I have written in 1/ use mbm (for bmp files) of mif (for svg format) files. Those files are usually stored in the application private folder, so only your applicaion can access them or in the "\resource\apps\" folder which has read-only access for all application.

    BR
    STeN

  5. #5
    Nokia Developer Moderator
    Join Date
    Sep 2004
    Location
    Tampere, Finland
    Posts
    11,359

    Re: How to add my own icon to List Box element??

    Is it so difficult to read that piece of code? Isn't it obvious that CreateIconLC reads two icons, identified by EMbmAvkonQgn_prop_nrtyp_address and EMbmAvkonQgn_prop_nrtyp_address_mask from a file whose name is hidden behind the KAvkonBitmapFile definition?

    Code:
    AknIconUtils::CreateIconLC(addressIcon, addressIconMask, KAvkonBitmapFile, EMbmAvkonQgn_prop_nrtyp_address, EMbmAvkonQgn_prop_nrtyp_address_mask );
    So, add new icons to your project and build an mbm/mif file with them, then modify KAvkonBitmapFile's definition to point to your file and replace EMbmAvkonQgn_prop_nrtyp_address with the ID of your icon.

    This is the idea. All the details missing you can find in the SDK help.
    -- Lucian

    If you are not yet a DVLUP member it is time to correct that mistake :) Click here to join: http://www.dvlup.com/lucian/Invite

  6. #6
    Regular Contributor
    Join Date
    Aug 2008
    Posts
    413

    Re: How to add my own icon to List Box element??

    hi stenlik and ltomuta,

    Thanks a lot for your so quick replys.But i am very much confused.What should be my first step??creating mbm file??Code is already ready with me..How to convert JPEG image to bitMap(bmp) files...??

    and ltomuta how to add new icons to my project and build an mbm/mif file with them??
    Rohanwaugh

  7. #7
    Nokia Developer Moderator
    Join Date
    Sep 2004
    Location
    Tampere, Finland
    Posts
    11,359

    Re: How to add my own icon to List Box element??

    To quote myself:
    Quote Originally Posted by ltomuta View Post
    All the details missing you can find in the SDK help.
    Aside from that there's Wiki, DiBo, Carbide's help and a lot of tutorials all over the net. Just search for the info and you will find it. You can at least try Google before asking a question.
    -- Lucian

    If you are not yet a DVLUP member it is time to correct that mistake :) Click here to join: http://www.dvlup.com/lucian/Invite

  8. #8
    Regular Contributor
    Join Date
    Aug 2008
    Posts
    413

    Re: How to add my own icon to List Box element??

    hi all,
    i have converted my JPG files to bmp files.i am taking help of post by original from following site for creation of mbm file.

    http://www.newlc.com/forum/how-create-mbm-file

    where i supposed to save the mbm file that is what should be the target path and Header path??

    Pls tell me this and half of my problems will be over.


    Rohanwaugh

  9. #9
    Nokia Developer Moderator
    Join Date
    Sep 2004
    Location
    Tampere, Finland
    Posts
    11,359

    Re: How to add my own icon to List Box element??

    Any path will do but since these icons are specific to your application only it is better to place the file in your private directory.
    -- Lucian

    If you are not yet a DVLUP member it is time to correct that mistake :) Click here to join: http://www.dvlup.com/lucian/Invite

  10. #10
    Registered User
    Join Date
    Aug 2008
    Location
    Hyderabad
    Posts
    35

    Re: How to add my own icon to List Box element??

    CArrayPtr<CGulIcon> *icons=new(ELeave)CAknIconArray(2);
    CleanupStack::PushL( icons );

    icons->AppendL( iEikonEnv->CreateIconL( KPath1,0) );

    icons->AppendL( iEikonEnv->CreateIconL( KPath2,0) );

    iListBox->ItemDrawer()->ColumnData()->SetIconArray(icons);
    CleanupStack::Pop();

    where KPath1 and KPath2 are corresponding to the .mbm path of the images
    _LIT16(KPath1, "\\system\\apps\\Sample\\Image1.mbm");
    _LIT16(KPath2, "\\system\\apps\\Sample\\Image2.mbm");

  11. #11
    Nokia Developer Moderator
    Join Date
    Sep 2004
    Location
    Tampere, Finland
    Posts
    11,359

    Re: How to add my own icon to List Box element??

    Quote Originally Posted by gangadhar.bonda View Post
    CArrayPtr<CGulIcon> *icons=new(ELeave)CAknIconArray(2);
    CleanupStack::PushL( icons );

    icons->AppendL( iEikonEnv->CreateIconL( KPath1,0) );

    icons->AppendL( iEikonEnv->CreateIconL( KPath2,0) );

    iListBox->ItemDrawer()->ColumnData()->SetIconArray(icons);
    CleanupStack::Pop();

    where KPath1 and KPath2 are corresponding to the .mbm path of the images
    _LIT16(KPath1, "\\system\\apps\\Sample\\Image1.mbm");
    _LIT16(KPath2, "\\system\\apps\\Sample\\Image2.mbm");
    This is an interesting piece of code. Would you care to explain it?
    -- Lucian

    If you are not yet a DVLUP member it is time to correct that mistake :) Click here to join: http://www.dvlup.com/lucian/Invite

Similar Threads

  1. How to add find pane (search item box) to list box
    By reuvenb in forum Symbian User Interface
    Replies: 2
    Last Post: 2008-11-26, 21:13
  2. column list box not shown correctly in landscape mode.
    By praveena_R in forum Symbian User Interface
    Replies: 3
    Last Post: 2007-12-14, 10:14
  3. How can we display a grid after click on a list box
    By jyotideep in forum Symbian User Interface
    Replies: 5
    Last Post: 2006-12-14, 04:59
  4. problem with list box
    By srkreddy999 in forum Symbian User Interface
    Replies: 2
    Last Post: 2005-09-30, 10:44
  5. List Box control on series -60
    By Nokia_Archive in forum Symbian Tools & SDKs
    Replies: 1
    Last Post: 2002-05-30, 21:03

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×