×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    9

    Grid icons not showing( Only numbers are showing)

    I
    am trying to create a simple selection grid to show some icons and related text in the grid. For that I have created the required .mbm file. But when I am trying to run the application no icons are showing, only numbers are showing.

    My code is as follows

    Code:
    #include <barsread.h>
    #include <aknlists.h>
    #include <eikappui.h>
    #include <badesca.h>
    #include <bamdesca.h>
    #include <eiktxlbm.h>//techview
    #include "MyContainer.h"
    #include <MyGrid_0xE06742D2.rsg>
    #include <gulicon.h>
    #include <fbs.h>
    #include <aknconsts.h>
    #include <akniconarray.h>
    #include <Portfolio.mbg>
    #include <akniconutils.h>
    
    
    _LIT(KAvkonBitmapFile2,"z:\\resource\\apps\\portfolio.mbm");
    
    
    CMyContainer* CMyContainer::NewL(const TRect& aRect)
    {
    	CMyContainer* self = NewLC(aRect);
    	CleanupStack::Pop(self);
    	return self;
    }
    
    CMyContainer* CMyContainer::NewLC(const TRect& aRect)
    {
    	CMyContainer* self = new (ELeave) CMyContainer;
    	CleanupStack::PushL(self);
    	self->ConstructL(aRect);
    	return self;
    }
    
    
    void CMyContainer::ConstructL(const TRect& aRect)
         {
    _LIT(KAvkonBitmapFile2,"z:\\resource\\apps\\portfolio.mbm");
     CreateWindowL();
         SetRect(aRect);
         
         // Create grid
         iGrid = new( ELeave ) CAknGrid;
         iGrid->SetContainerWindowL( *this );  
         
         iGridModel = new (ELeave) CAknGridM;
         iGrid->SetModel(iGridModel);
    
         // Construct grid 
         iGrid->ConstructL(this,EAknListBoxSelectionGrid);
    
         // Set grid layout, and scrolling
         iGrid->SetLayoutL(EFalse,ETrue,ETrue,4,3,TSize(50,50),5,5);
         iGrid->SetPrimaryScrollingType(CAknGridView::EScrollIncrementLineAndLoops);
         iGrid->SetSecondaryScrollingType(CAknGridView::EScrollIncrementLineAndLoops);
         AknListBoxLayouts::SetupStandardGrid(*iGrid);
         
         // Adds ICONS from AVKON`s bitmap file
        // Create icon array with granularity of 1 icon 
        CArrayPtr< CGulIcon >* icons = new(ELeave) CAknIconArray(1);
        CleanupStack::PushL( icons );
    //    _LIT(KMbmPath, "Z:\\system\\data\\portfolio.mbm");
        // Load the bitmap for mail icon 
        CFbsBitmap* bitmap = iEikonEnv->CreateBitmapL( KAvkonBitmapFile2, EMbmPortfolioAdd_icon);
        CleanupStack::PushL( bitmap );
        // Load the mask for mail icon 
        CFbsBitmap* mask = iEikonEnv->CreateBitmapL( KAvkonBitmapFile2, EMbmPortfolioAdd_icon );
        CleanupStack::PushL( mask ); 
        // Append the mail icon to icon array 
        icons->AppendL( CGulIcon::NewL( bitmap, mask ) );
        icons->AppendL( CGulIcon::NewL( bitmap, mask ) );
        icons->AppendL( CGulIcon::NewL( bitmap, mask ) );
        CleanupStack::Pop(2); // bitmap, mask 
        // Attach icon array to grid’s item drawer 
        iGrid->ItemDrawer()->FormattedCellData()->SetIconArrayL( icons );
        CleanupStack::Pop(1);
         
         CDesCArray *gridItemArray = static_cast<CDesCArray*>( iGridModel->ItemTextArray() );   
         gridItemArray->AppendL( _L("0\tItem1") );
         gridItemArray->AppendL( _L("1\tItem2") );
         gridItemArray->AppendL( _L("2\tItem3") );
         gridItemArray->AppendL( _L("0\tItem4") );
         gridItemArray->AppendL( _L("1\tItem5") );
         gridItemArray->AppendL( _L("2\tItem6") );
         gridItemArray->AppendL( _L("0\tItem7") );
         gridItemArray->AppendL( _L("1\tItem8") );
         gridItemArray->AppendL( _L("2\tItem9") );
         gridItemArray->AppendL( _L("0\tItem10") );
         iGrid->HandleItemAdditionL();
    
         
         
         
         AknListBoxLayouts::SetupFormGfxCell( *iGrid, iGrid->ItemDrawer(),
    							             0, 
    							             0, 0, 0, 0, 
    							             50, 50, 
    							             TPoint(0,0), TPoint(32,32) ); 
    
         // Setup the layout of the text in the cell.
         AknListBoxLayouts::SetupFormTextCell( *iGrid, iGrid->ItemDrawer(),
                                              0, LatinBold16(), 0, 0, 0, 47, 
                                              60, CGraphicsContext::ECenter, 
                                              TPoint(0,32), TPoint(50,50) ); 
         // Activate grid
         iGrid->SetRect( Rect() );
         iGrid->ActivateL();
         ActivateL();
    }
    
    CMyContainer::CMyContainer()
    	{
    	
    	}
    
    CMyContainer::~CMyContainer()
    	{
    	if(iGridModel)
    		{
    		delete iGridModel;
    		iGridModel = NULL;
    		}
    	if(iGrid)
    		{
    		delete iGrid;
    		iGrid = NULL;
    		}
    	}
    
    
    void CMyContainer::Draw(const TRect &aRect)
    	{
    	CWindowGc& gc = SystemGc();
    
    	// Gets the control's extent
    	TRect drawRect( Rect());
    	}
    
    void CMyContainer::SizeChanged()
    	{
    	DrawNow();
    	}
    
    
    TInt CMyContainer::CountComponentControls() const{
    	return 1;
    }
    
    CCoeControl * CMyContainer::ComponentControl(TInt aIndex) const{
    	return iGrid;
    }
    Please help me to identify the problem.

  2. #2
    Regular Contributor
    Join Date
    Apr 2006
    Location
    India
    Posts
    383

    Re: Grid icons not showing( Only numbers are showing)

    Seems like its a baseline issue.

    Check
    S60 3rd Edition SDK for Symbian OS, MR
    Developer Guides >> Avkon UI Resources – Grids >>Setting Up the Cell Structure

    for more details.
    Regards,
    Shilpa Kulkarni

  3. #3
    Registered User
    Join Date
    Nov 2007
    Posts
    9

    Re: Grid icons not showing( Only numbers are showing)

    Hi Shilpa13
    Thanks for the reply. The problem have solved. The problem was in calling
    Code:
    // Setup the layout of the text in the cell.
         AknListBoxLayouts::SetupFormTextCell( *iGrid, iGrid->ItemDrawer(),
                                              0, LatinBold16(), 0, 0, 0, 47, 
                                              60, CGraphicsContext::ECenter, 
                                              TPoint(0,32), TPoint(50,50) );
    However after correcting the parameter now the icons is shown properly.

Similar Threads

  1. icons not showing in listbox
    By adamlah in forum Symbian
    Replies: 6
    Last Post: 2009-01-29, 09:54
  2. Grid without Icons...?
    By remesh in forum Symbian User Interface
    Replies: 2
    Last Post: 2008-08-06, 09:30
  3. Grid icons problem
    By sriramadasu in forum Symbian
    Replies: 0
    Last Post: 2006-05-17, 06:23
  4. Icons not showing on real device
    By advocatee in forum Symbian
    Replies: 0
    Last Post: 2003-10-23, 07:30

Posting Permissions

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