×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Regular Contributor
    Join Date
    Mar 2007
    Posts
    235

    Question Need Help with grid here

    I am trying to implement a grid fully from resource , as it would be a static one only . I have done till this . Right now I want to show some text in it .My problem is that the grid do not show . Do I need to add something ?

    Code:
    RESOURCE GRID r_selectiongrid
    {
    //height = 5; // in items
    //width = 10; 
    flags = EAknListBoxSelectionGrid;
    style = r_selectiongrid_style;
    array_id = r_selectiongrid_items;
    }
    
    RESOURCE GRID_STYLE r_selectiongrid_style
    {
    layoutflags = EAknGridHorizontalOrientation |EAknGridLeftToRight | EAknGridTopToBottom;
    primaryscroll = EAknGridFollowsItemsAndLoops;
    secondaryscroll = EAknGridFollowsItemsAndLoops;
    itemsinprimaryorient = 3;
    itemsinsecondaryorient = 3;
    gapwidth = 5;
    gapheight = 5;
    width = 50;
    height = 50;
    }
    
    RESOURCE ARRAY r_selectiongrid_items
    {
    items =
    {
    LBUF { txt = "aaa"; },
    LBUF { txt = "bbb"; },
    LBUF { txt = "ccc"; },
    LBUF { txt = "ddd"; },
    LBUF { txt = "eee"; },
    LBUF { txt = "fff"; },
    LBUF { txt = "ggg"; },
    LBUF { txt = "hhh"; },
    LBUF { txt = "iii"; }
    };
    }
    I am implementing the view class as the container for grid .

    Code:
    void CSimpleGridAppView::ConstructL( const TRect& aRect )
    {
    CreateWindowL();
    	// Set the windows size
    	SetRect( aRect );
    	// Activate the window, which makes it ready to be drawn
    	ActivateL();
    	iGrid = new( ELeave ) CAknGrid;
    	iGrid->SetContainerWindowL( *this );
    	TResourceReader reader; 
    	CEikonEnv::Static()->CreateResourceReaderLC(reader, R_SELECTIONGRID);
    	iGrid->ConstructFromResourceL(reader);
             iGrid->ActivateL();
            // Setup text foreground and background colors to default
           AknListBoxLayouts::SetupStandardGrid( *iGrid );
           // Setup the graphics subcell
          AknListBoxLayouts::SetupFormGfxCell(
           *iGrid, // Reference to grid control
            iGrid->ItemDrawer(), // Pointer to the item drawer
            0, // Column index
            0, // Left position
            0, // Top position
            0, // Right - unused
            0, // Bottom - unused
            50, // Width
            32, // Height
             TPoint(0,0), // Start position
             TPoint(32, 32)); // End position
    
           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->SetFocus(ETrue);
    	iGrid->DrawNow();
    
    	CleanupStack::PopAndDestroy();
    }
    Last edited by gigglie; 2008-01-01 at 16:41.

  2. #2
    Registered User
    Join Date
    Apr 2005
    Location
    Barcelona
    Posts
    1,678

    Re: Need Help with grid here

    I suggest you use a working example as a starting point. Check the sdk examples, wiki or similar resources.

  3. #3
    Regular Contributor
    Join Date
    Mar 2007
    Posts
    235

    Re: Need Help with grid here

    Hi PushL
    Do you know 1 working example , please give to me if you have one .

  4. #4
    Registered User
    Join Date
    Mar 2006
    Location
    India
    Posts
    503

    Re: Need Help with grid here

    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 = GAMES_GRID_ITEM1_TEXT;
    },
    LBUF
    {
    txt = GAMES_GRID_ITEM2_TEXT;
    },
    LBUF
    {
    txt = GAMES_GRID_ITEM3_TEXT;
    },
    LBUF
    {
    txt = GAMES_GRID_ITEM4_TEXT;
    },
    LBUF
    {
    txt = GAMES_GRID_ITEM5_TEXT;
    },
    LBUF
    {
    txt = GAMES_GRID_ITEM6_TEXT;
    },
    LBUF
    {
    txt = GAMES_GRID_ITEM7_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=2; // number of items vertically per screen
    gapwidth=5;
    gapheight=5;
    height = 68;
    width = 50;

    }
    Regards
    Kamal :)
    ------------------
    You never expect what expects you.

  5. #5
    Registered User
    Join Date
    Mar 2006
    Location
    India
    Posts
    503

    Re: Need Help with grid here

    class CSimpleGridGamesGrid : public CAknGrid
    {
    public: // Constructors and destructor

    void ConstructL(TInt aGridResource, TInt aIconFileResource);

    private: // from CoeControl

    void SizeChanged();

    private: // members
    void SetupGrid();
    void SetupGridIconsL(TInt aIconFileResource);

    };
    Regards
    Kamal :)
    ------------------
    You never expect what expects you.

  6. #6
    Registered User
    Join Date
    Mar 2006
    Location
    India
    Posts
    503

    Re: Need Help with grid here

    void CSimpleGridGamesGrid::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, EMbmSimplegridSnap, EMbmSimplegridCard_mask));
    icons->AppendL(iEikonEnv->CreateIconL(*iconFileName, EMbmSimplegridGolf, EMbmSimplegridCard_mask));
    icons->AppendL(iEikonEnv->CreateIconL(*iconFileName, EMbmSimplegridClock, EMbmSimplegridCard_mask));
    icons->AppendL(iEikonEnv->CreateIconL(*iconFileName, EMbmSimplegridAces, EMbmSimplegridCard_mask));
    icons->AppendL(iEikonEnv->CreateIconL(*iconFileName, EMbmSimplegridHearts, EMbmSimplegridCard_mask));
    icons->AppendL(iEikonEnv->CreateIconL(*iconFileName, EMbmSimplegridRummy, EMbmSimplegridCard_mask));
    icons->AppendL(iEikonEnv->CreateIconL(*iconFileName, EMbmSimplegridPoker, EMbmSimplegridCard_mask));
    CleanupStack::Pop(icons);
    CleanupStack::PopAndDestroy(iconFileName);

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

    }
    Regards
    Kamal :)
    ------------------
    You never expect what expects you.

  7. #7
    Registered User
    Join Date
    Apr 2005
    Location
    Barcelona
    Posts
    1,678

    Re: Need Help with grid here

    Quote Originally Posted by gigglie View Post
    Hi PushL
    Do you know 1 working example , please give to me if you have one .
    Did you check the sdk doc? See Developer Guides >> Avkon UI Resources – Grids
    It contains most of what you'd ever need..

  8. #8
    Regular Contributor
    Join Date
    Mar 2007
    Posts
    235

    Re: Need Help with grid here

    I was working with the S60 Avkon grid documentation and forums here and all I could translate was above code . So I was kind of trying to make it work following the instructions there .

  9. #9
    Regular Contributor
    Join Date
    Mar 2007
    Posts
    235

    Re: Need Help with grid here

    Quote Originally Posted by kamaljaiswal View Post
    void CSimpleGridGamesGrid::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, EMbmSimplegridSnap, EMbmSimplegridCard_mask));
    icons->AppendL(iEikonEnv->CreateIconL(*iconFileName, EMbmSimplegridGolf, EMbmSimplegridCard_mask));
    icons->AppendL(iEikonEnv->CreateIconL(*iconFileName, EMbmSimplegridClock, EMbmSimplegridCard_mask));
    icons->AppendL(iEikonEnv->CreateIconL(*iconFileName, EMbmSimplegridAces, EMbmSimplegridCard_mask));
    icons->AppendL(iEikonEnv->CreateIconL(*iconFileName, EMbmSimplegridHearts, EMbmSimplegridCard_mask));
    icons->AppendL(iEikonEnv->CreateIconL(*iconFileName, EMbmSimplegridRummy, EMbmSimplegridCard_mask));
    icons->AppendL(iEikonEnv->CreateIconL(*iconFileName, EMbmSimplegridPoker, EMbmSimplegridCard_mask));
    CleanupStack::Pop(icons);
    CleanupStack::PopAndDestroy(iconFileName);

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

    }
    Hi Kamal , but I was yet to implement the icon bit , I was only trying the elementary text thing . If they show up right I would be soon to follow with this one . But thanx for your help buddy.

Similar Threads

  1. scrollbar with the grid
    By agirllikeyou in forum Symbian User Interface
    Replies: 9
    Last Post: 2010-02-05, 09:46
  2. How to make simple GRID list with border and highlighted selection.
    By khurshed79 in forum Symbian User Interface
    Replies: 2
    Last Post: 2009-01-25, 10:25
  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. Grid refresh problem(Need urgent help)
    By ekramulhuq in forum Symbian C++
    Replies: 3
    Last Post: 2006-10-19, 07:09
  5. help me for the grid problems
    By bention in forum Symbian C++
    Replies: 3
    Last Post: 2006-05-01, 15:34

Posting Permissions

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