×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Oct 2006
    Posts
    40

    code is compiled successfully but icons are not displayed on my Grids

    Hi,
    All Happy new year .....................!!!!!!!
    I am working on Symbian C++ (S60) in codewarrior............ I am facing a problem in showing my icons in my grids. I have done the same thing in Listbox and its working fine ....... here i can display the text in the grids ..... I have six grids and i want to display icons over it ...... but its not working even though code is compiled successfully... plz help me ..... I am sending my container.cpp file and .rss file ..

    //------------------------------------------------------------
    //MultiViewsContainer1.cpp
    //------------------------------------------------------------

    #include <MultiViews.rsg>
    #include <MULTIVIEWS.mbg>

    #include "MultiViewsContainer1.h"

    #include <AknGrid.h>
    #include <AknGridView.h>
    #include <AknGridM.h>
    #include <AknIconArray.h>
    #include <AknLists.h>
    #include <AknQueryDialog.h>

    #include <barsread.h>
    #include <coemain.h>

    #include <e32base.h>
    #include <GULICON.H>
    //constants
    const TInt KNumberOfIcons = 6;//the count if icon
    const TInt KGraphicsHeight = 28;//icon height
    const TInt KTextColor = 215;//text color



    //AknLists.h
    // ========================= MEMBER FUNCTIONS ==================================


    // -----------------------------------------------------------------------------
    // CMultiViewsContainer1::NewL()
    // Two-phased constructor.
    // -----------------------------------------------------------------------------
    //
    CMultiViewsContainer1* CMultiViewsContainer1::NewL( const TRect& aRect )
    {
    CMultiViewsContainer1* self = CMultiViewsContainer1::NewLC( aRect );
    CleanupStack::Pop( self );
    return self;
    }

    // -----------------------------------------------------------------------------
    // CMultiViewsContainer1::NewLC()
    // Two-phased constructor.
    // -----------------------------------------------------------------------------
    //
    CMultiViewsContainer1* CMultiViewsContainer1::NewLC( const TRect& aRect )
    {
    CMultiViewsContainer1* self = new ( ELeave ) CMultiViewsContainer1;
    CleanupStack::PushL( self );
    self->ConstructL( aRect );
    return self;
    }

    // -----------------------------------------------------------------------------
    // CMultiViewsContainer1::ConstructL()
    // Symbian 2nd phase constructor can leave.
    // -----------------------------------------------------------------------------
    //
    void CMultiViewsContainer1::ConstructL( const TRect& aRect )
    {
    CreateWindowL();

    iGrid = new( ELeave ) CAknGrid;
    iGrid->SetContainerWindowL( *this );

    TResourceReader reader;
    CEikonEnv::Static()->CreateResourceReaderLC(reader, R_SELECTIONGRID);
    iGrid->ConstructFromResourceL(reader);
    CleanupStack::PopAndDestroy();


    // Setup the text subcell

    AknListBoxLayouts::SetupFormTextCell(

    *iGrid, // Reference to grid

    iGrid->ItemDrawer(),// Pointer to the item drawer

    1, // Column index

    LatinBold12(), // Font

    215, // Color (215 = black)

    0, // Left margin

    0, // Right margin - unused

    50 - 3, // Baseline

    50, // Text width

    CGraphicsContext::ECenter, // Text alignment

    TPoint(0, 32), // Start position

    TPoint(50, 50)); // End position


    iGrid->MakeVisible( ETrue );
    iGrid->SetFocus( ETrue );
    iGrid->ActivateL();

    //icon display

    SetupGridIconsL();
    SizeChanged();
    SetRect( aRect );
    ActivateL();


    DrawNow();
    }

    void CMultiViewsContainer1::SetupGridIconsL()
    {
    _LIT(KIconsFilename, "\\system\\apps\\multiviews\\multiviews.mbm");


    CArrayPtr<CGulIcon>* icons = new(ELeave) CAknIconArray(KNumberOfIcons);
    CleanupStack::PushL(icons);
    icons->AppendL(CEikonEnv::Static()->CreateIconL(KIconsFilename, EMbmMultiviewsGriditem , EMbmMultiviewsGriditemm));
    icons->AppendL(iEikonEnv->CreateIconL(KIconsFilename, EMbmMultiviewsTrains, EMbmMultiviewsTrainsm));
    icons->AppendL(iEikonEnv->CreateIconL(KIconsFilename, EMbmMultiviewsAirways, EMbmMultiviewsAirwaysm));
    icons->AppendL(iEikonEnv->CreateIconL(KIconsFilename, EMbmMultiviewsGriditem , EMbmMultiviewsGriditemm));
    icons->AppendL(iEikonEnv->CreateIconL(KIconsFilename, EMbmMultiviewsTrains, EMbmMultiviewsTrainsm));
    icons->AppendL(iEikonEnv->CreateIconL(KIconsFilename, EMbmMultiviewsAirways, EMbmMultiviewsAirwaysm));

    CleanupStack::Pop(icons);


    iGrid->ItemDrawer()->FormattedCellData()->SetIconArrayL(icons); // passing ownership of icons



    }

    CMultiViewsContainer1::CMultiViewsContainer1()
    {

    }

    CMultiViewsContainer1::~CMultiViewsContainer1()
    {
    delete iGrid;
    }


    /*void CMultiViewsContainer1::SizeChanged()
    {

    if(iGrid)
    {
    iGrid->SetRect(Rect());
    }

    }
    */
    #define KGridPosition TPoint(0,0)

    void CMultiViewsContainer1::SizeChanged()
    {
    if (iGrid)
    {
    iGrid->SetExtent(KGridPosition,Rect().Size());
    }
    }




    void CMultiViewsContainer1::HandleControlEventL(
    CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
    {

    }


    TKeyResponse CMultiViewsContainer1::OfferKeyEventL(
    const TKeyEvent& aKeyEvent,
    TEventCode aType )
    {

    if(iGrid)
    return iGrid->OfferKeyEventL( aKeyEvent, aType );
    else
    return EKeyWasNotConsumed;
    }


    // -----------------------------------------------------------------------------
    // CMultiViewsContainer1::CountComponentControls() const
    // returns number of controls inside this container.
    // -----------------------------------------------------------------------------
    //
    TInt CMultiViewsContainer1::CountComponentControls() const
    {
    return 1;
    }


    // -----------------------------------------------------------------------------
    // CMultiViewsContainer1::ComponentControl() const
    // returns pointer of controls inside this container
    // -----------------------------------------------------------------------------
    //
    CCoeControl* CMultiViewsContainer1::ComponentControl( TInt aIndex ) const
    {
    switch ( aIndex )
    {
    case 0:
    return iGrid;

    default:
    return NULL;
    }
    }

    // -----------------------------------------------------------------------------
    // CMultiViewsContainer1::Draw() const
    // Draws the display
    // -----------------------------------------------------------------------------
    //
    void CMultiViewsContainer1::Draw( const TRect& aRect ) const
    {
    CWindowGc& gc = SystemGc();
    gc.SetPenStyle( CGraphicsContext::ENullPen );
    gc.SetBrushColor( TRgb(0xfff123)); //KRgbBlue );
    gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
    gc.DrawRect( aRect );
    }



    TInt CMultiViewsContainer1::UpdateFromModelGrid()
    {

    pos = iGrid->CurrentDataIndex();
    if(pos==0)
    {
    ..........
    .............................
    }
    ........................................
    .......................................................

    else
    {
    iEikonEnv->InfoMsg( _L("You have pressed Ok button 6") );
    return 6;
    }


    }


    // End of File
    //------------------------------------------------------------------------


    // .RSS file
    RESOURCE GRID r_selectiongrid
    { array_id = r_selectiongrid_items;
    flags = EAknListBoxSelectionGrid;
    style = r_selectiongrid_style;
    }
    RESOURCE GRID_STYLE r_selectiongrid_style
    { layoutflags = EAknGridHorizontalOrientation | EAknGridLeftToRight | EAknGridTopToBottom;
    primaryscroll = EAknGridFollowsItemsAndLoops;
    secondaryscroll = EAknGridFollowsItemsAndLoops;
    itemsinprimaryorient = 3;
    itemsinsecondaryorient = 3;
    gapwidth = 5;
    gapheight = 5;
    width = 55;
    height = 70;
    }

    RESOURCE ARRAY r_selectiongrid_items
    {
    items =
    { LBUF { txt = "0\tHospitals"; },
    LBUF { txt = "1\tRestaurant"; },
    LBUF { txt = "2\tATMs"; },
    LBUF { txt = "0\tEntertainment"; },
    LBUF { txt = "2\tGenie"; } ,
    LBUF { txt = "3\tPetrol Pumps"; } //,

    };
    }
    Thanks & Regards

    Jyotideep Bhuyan

  2. #2
    Registered User
    Join Date
    Jun 2012
    Posts
    10

    Re: code is compiled successfully but icons are not displayed on my Grids

    hello,I am facing the same problem.
    this is my link:http://www.developer.nokia.com/Commu...318#post902318
    what's your solution?
    can you tell me?
    thx.

  3. #3
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,166

    Re: code is compiled successfully but icons are not displayed on my Grids

    there are no points really on popping up 5 year old posts, so its better to stick on making new threads and specifying the problem in details inside it.

Similar Threads

  1. Replies: 2
    Last Post: 2007-10-05, 20:40
  2. Fixing a bug in an already obfuscated midlet (no source code) ?
    By SPGremlin in forum Mobile Java General
    Replies: 1
    Last Post: 2004-01-12, 21:52
  3. Problem in compatability of compiled code on symbian OS v6.1 and v7.0
    By pratbrat77 in forum Symbian Tools & SDKs
    Replies: 2
    Last Post: 2003-11-23, 21:51
  4. Replies: 2
    Last Post: 2003-11-09, 14:00
  5. Anyone successfully compiled and run Blockgame?
    By vivian_cheng in forum Mobile Java Tools & SDKs
    Replies: 0
    Last Post: 2003-05-02, 13:05

Posting Permissions

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