×

Discussion Board

Results 1 to 7 of 7

Hybrid View

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

    Unable to display icons in 3*3 grids

    hello everyone,
    I am freshman.I wrote a project(3*3 grids),which there is one icon in each grid.
    Now I got a problem,I can not display icons in 3*3 grids.
    my code as follow:
    I new CSimpleGridGamesGrid in "MainContainer.cpp":
    void CMainContainer::ConstructL(const TRect& aRect)
    {
    CreateWindowL();

    // Construct the grid
    iGamesGrid = new (ELeave)CSimpleGridGamesGrid;
    iGamesGrid->SetContainerWindowL(*this);
    iGamesGrid->ConstructL(R_SIMPLEGRID_GAMES_GRID, R_ICON_FILE_NAME);

    // Observe the grid
    iGamesGrid->SetListBoxObserver(this);

    SetRect(aRect);
    ActivateL();
    }
    and "MySimpleGridGamesGrid.cpp" as follow:
    void CMySimpleGridGamesGrid::ConstructL(TInt aGridResource, TInt aIconFileResource)
    {
    // Construct the grid from resource
    TResourceReader reader;
    CEikonEnv::Static()->CreateResourceReaderLC(reader, aGridResource);
    ConstructFromResourceL(reader);
    CleanupStack::PopAndDestroy(); // reader

    // Set up the icons
    SetupGridIconsL (aIconFileResource);

    // Draw the grid
    SizeChanged();
    }


    void CMySimpleGridGamesGrid::SetupGridIconsL(TInt aIconFileResource)
    {
    // Get the name of the file containing the icons
    HBufC* iconFileName;
    iconFileName = StringLoader::LoadLC(aIconFileResource); // Pushes iconFileName onto the Cleanup Stack.

    // Create an array of icons, reading them from the file
    CArrayPtr<CGulIcon>* icons = new(ELeave) CAknIconArray(KNumberOfIcons);
    CleanupStack::PushL(icons);
    icons->AppendL(iEikonEnv->CreateIconL(*iconFileName, EMbmMymygridGolf));
    icons->AppendL(iEikonEnv->CreateIconL(*iconFileName, EMbmMymygridSnap));
    icons->AppendL(iEikonEnv->CreateIconL(*iconFileName, EMbmMymygridClock));
    icons->AppendL(iEikonEnv->CreateIconL(*iconFileName, EMbmMymygridAces));
    icons->AppendL(iEikonEnv->CreateIconL(*iconFileName, EMbmMymygridHearts));
    icons->AppendL(iEikonEnv->CreateIconL(*iconFileName, EMbmMymygridRummy));
    icons->AppendL(iEikonEnv->CreateIconL(*iconFileName, EMbmMymygridPoker));
    icons->AppendL(iEikonEnv->CreateIconL(*iconFileName, EMbmMymygridHmd));
    icons->AppendL(iEikonEnv->CreateIconL(*iconFileName, EMbmMymygridBmd));
    CleanupStack::Pop(icons);
    CleanupStack::PopAndDestroy(iconFileName);

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

    }

    void CMySimpleGridGamesGrid::SetMyGrid()
    {
    // Setup text foreground and background colours to default
    AknListBoxLayouts::SetupStandardGrid(*this);


    // // Get local copies of data we will need
    CFormattedCellListBoxItemDrawer* itemDrawer = this->ItemDrawer();
    TInt cellWidth = ColumnWidth();
    TInt cellHeight = ItemHeight();


    // // Set up graphics subcells
    AknListBoxLayouts::SetupFormGfxCell(*this, //the grid
    itemDrawer, // the grid's drawer
    0, // index of the graphic within item strings
    0, // left position
    0, // top position
    0, // right - unused
    0, // bottom - unused
    cellWidth, // width of graphic
    KGraphicsHeight, // height of graphic
    TPoint (0, 0), // start position
    TPoint (0 , 0)); // end position

    // // Set up text subcells
    const CFont* KFont = LatinBold12();
    TInt baseline = cellHeight - KFont->DescentInPixels() - 1;

    AknListBoxLayouts::SetupFormTextCell(*this, // the grid
    itemDrawer, // the grid's drawer
    1, // index of text within item strings
    KFont, // the font for the text
    KTextColor, // the color of the text - N.B. although commented out in the header file, this is still used!
    0, // left margin
    0, // right margin - unused
    baseline, // Baseline
    cellWidth, // text width (would need to take margin into account if set, i.e. - lm)
    CGraphicsContext::ECenter, // Alignment
    TPoint (0, 0), // start position
    TPoint(cellWidth, cellHeight)); // end position
    }

    void CMySimpleGridGamesGrid::SizeChanged()
    {
    CAknGrid::SizeChanged();
    SetMyGrid();
    }
    and RSS file as follow:
    // RESOURCE DEFINITIONS
    RESOURCE RSS_SIGNATURE
    {
    }

    RESOURCE TBUF r_default_document_name
    {
    buf="MYMY";
    }

    RESOURCE EIK_APP_INFO
    {
    menubar = r_menubar_view_main;
    cba = R_AVKON_SOFTKEYS_OPTIONS_EXIT;
    }


    RESOURCE AVKON_VIEW r_view_main
    {
    menubar = r_menubar_view_main;
    cba = R_AVKON_SOFTKEYS_OPTIONS_EXIT;
    }
    RESOURCE MENU_BAR r_menubar_view_main
    {
    titles =
    {
    MENU_TITLE {menu_pane = r_menupane_view_main;}
    };
    }


    RESOURCE MENU_PANE r_menupane_view_main
    {
    items =
    {
    MENU_ITEM
    {
    command = ECommand1;
    txt = qtn_command1;
    },
    MENU_ITEM
    {
    command = ECommand2;
    txt = qtn_command2;
    },
    MENU_ITEM
    {
    command = EHelp;
    txt = qtn_help;
    },
    MENU_ITEM
    {
    command = EAbout;
    txt = qtn_about;
    },
    MENU_ITEM
    {
    command = EAknSoftkeyExit;
    txt = qtn_exit;
    }
    };
    }

    RESOURCE DIALOG r_about_query_dialog
    {
    flags = EGeneralQueryFlags | EEikDialogFlagNoBorder | EEikDialogFlagNoShadow;
    buttons = R_AVKON_SOFTKEYS_OK_EMPTY;
    items=
    {
    DLG_LINE
    {
    type = EAknCtPopupHeadingPane;
    id = EAknMessageQueryHeaderId;
    itemflags = EEikDlgItemNonFocusing;
    control = AVKON_HEADING
    {
    };
    },
    DLG_LINE
    {
    type = EAknCtMessageQuery;
    id = EAknMessageQueryContentId;
    control = AVKON_MESSAGE_QUERY
    {
    };
    }
    };
    }


    RESOURCE TBUF32 r_caption_string { buf=qtn_caption_string; }
    RESOURCE TBUF32 r_about_dialog_title { buf=qtn_about_dialog_title; }
    RESOURCE TBUF r_about_dialog_text { buf=qtn_about_dialog_text; }
    RESOURCE TBUF r_command1_text { buf=qtn_command1_text; }


    RESOURCE LOCALISABLE_APP_INFO r_localisable_app_info
    {
    short_caption = qtn_caption_string;
    caption_and_icon =
    CAPTION_AND_ICON_INFO
    {
    caption = qtn_caption_string;

    number_of_icons = 1;
    icon_file = "\\resource\\apps\\MyMyGrid_0xEB952DA2.mif";
    };
    }

    RESOURCE GRID R_SIMPLEGRID_GAMES_GRID
    {
    array_id = r_simplegrid_games_grid_items;
    flags = EAknListBoxSelectionGrid;
    style=r_simplegrid_games_grid_style;
    }

    RESOURCE ARRAY r_simplegrid_games_grid_items
    {
    items =
    {
    LBUF
    {
    txt = qtn_grid_item1_text;
    },
    LBUF
    {
    txt = qtn_grid_item2_text;
    },
    LBUF
    {
    txt = qtn_grid_item3_text;
    },
    LBUF
    {
    txt = qtn_grid_item4_text;
    },
    LBUF
    {
    txt = qtn_grid_item5_text;
    },
    LBUF
    {
    txt = qtn_grid_item6_text;
    },
    LBUF
    {
    txt = qtn_grid_item7_text;
    },
    LBUF
    {
    txt = qtn_grid_item8_text;
    },
    LBUF
    {
    txt = qtn_grid_item9_text;
    }

    };
    }



    RESOURCE GRID_STYLE r_simplegrid_games_grid_style
    {
    layoutflags=EAknGridHorizontalOrientation| EAknGridLeftToRight | EAknGridTopToBottom;
    primaryscroll= EAknGridFollowsItemsAndLoops; // horizontal scroll
    secondaryscroll=EAknGridFollowsItemsAndLoops; // vertical scroll
    itemsinprimaryorient=3; // number of items horizontally per screen
    itemsinsecondaryorient=3; // number of items vertically per screen
    gapwidth=0;
    gapheight=0;
    height = 80;
    width = 78;
    }

    RESOURCE TBUF r_icon_file_name
    {
    buf = "\\system\\apps\\MyMyGrid.mbm";
    }
    and mmp file as follow:
    TARGET MyMyGrid_0xEB952DA2.exe
    TARGETTYPE exe
    UID 0x100039CE 0xEB952DA2

    SOURCEPATH ..\src
    SOURCE MyMyGrid.cpp
    SOURCE MyMyGridApplication.cpp
    SOURCE MyMyGridAppView.cpp
    SOURCE MyMyGridAppUi.cpp
    SOURCE MyMyGridDocument.cpp

    SOURCEPATH ..\data

    START RESOURCE MyMyGrid.rss
    HEADER
    TARGET MyMyGrid_0xEB952DA2
    TARGETPATH resource\apps
    END //RESOURCE

    START RESOURCE MyMyGrid_reg.rss
    TARGET MyMyGrid_0xEB952DA2_reg
    TARGETPATH \private\10003a3f\apps
    END //RESOURCE

    USERINCLUDE ..\inc
    USERINCLUDE ..\help

    SYSTEMINCLUDE \epoc32\include

    LIBRARY euser.lib
    LIBRARY apparc.lib
    LIBRARY cone.lib
    LIBRARY eikcore.lib
    LIBRARY avkon.lib
    LIBRARY commonengine.lib
    LIBRARY efsrv.lib
    LIBRARY estor.lib
    LIBRARY aknnotify.lib
    LIBRARY hlplch.lib
    LIBRARY eikcoctl.lib
    LIBRARY gdi.lib
    LIBRARY egul.lib
    LIBRARY aknicon.lib

    LANG SC

    VENDORID 0
    SECUREID 0xEB952DA2
    CAPABILITY ReadUserData

    #ifdef ENABLE_ABIV2_MODE
    DEBUGGABLE_UDEBONLY
    #endif
    // End of File
    SOURCEPATH ..\src
    SOURCE CMyMainView.cpp MyMainContainer.cpp MySimpleGridGamesGrid.cpp
    START BITMAP MyMyGrid.mbm
    HEADER
    TARGETPATH \system\apps
    SOURCEPATH ..\gfx
    SOURCE c24 Golf.bmp snap.bmp clock.bmp aces.bmp Hearts.bmp Rummy.bmp Poker.bmp hmd.bmp bmd.bmp
    END

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

    Re: Unable to display icons in 3*3 grids

    It is not clear what happens. Does the grid appear, just without any icons? Does it have some labels at the same time?
    What are those qtn_grid_itemx_text-s exactly? Are they following the required format (probably something like "<icon number>\t<text label>", though I have not used grids in fact)?
    At the first glance the code itself seems to be fine, however if it crashes, please specify how (http://www.developer.nokia.com/Commu...ded_panic_code)

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

    Re: Unable to display icons in 3*3 grids

    yes,the grid appear, just without any icons。there are not labels at the same time.

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

    Re: Unable to display icons in 3*3 grids

    the code run steady, never crash.

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

    Re: Unable to display icons in 3*3 grids

    I would compare it to the Wiki examples: http://www.developer.nokia.com/Commu...i/Grid_example and make sure the layouts set for the grid cells are actually something that would be showing the content there.

    Also fully debugging the code in emulator to make sure all parts are executed as designed would be really good to be done.

  6. #6
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,689

    Re: Unable to display icons in 3*3 grids

    It is still not clear what those qtn_grid_itemx_text-s contain. If you have problems with locating them, check for .loc or .rls files in the project (usually in the data folder, perhaps in group).

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

    Re: Unable to display icons in 3*3 grids

    thank wizard_hu_ and symbianyucca,I solved the problem by following your suggestions,especially thank wizard_hu_,the codes run exactly after defined the grid_itemX of the grids in the .rls file.
    thank you two very much!

Similar Threads

  1. code is compiled successfully but icons are not displayed on my Grids
    By jyotideep in forum Symbian User Interface
    Replies: 2
    Last Post: 2012-08-28, 10:51
  2. unable to add icons to grid control
    By tlr in forum Symbian User Interface
    Replies: 1
    Last Post: 2009-04-09, 05:22
  3. Display icons in Grid
    By stephen-cheung in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 7
    Last Post: 2008-09-18, 06:19
  4. Icons display on emulator, but not on Nokia 7650. why?
    By chrisnsx in forum Mobile Java Media (Graphics & Sounds)
    Replies: 3
    Last Post: 2003-05-05, 07:20
  5. Can ListBox display different icons?
    By liuajie in forum Symbian User Interface
    Replies: 2
    Last Post: 2002-11-07, 04:32

Posting Permissions

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