Grid Problem:Plz help
Login to reply to this topic.
Mon, 2006-06-26 11:35
Joined: 2006-06-03
Forum posts: 26
Hi all,

I m making a grid application.

My code is as below:

Code:
in xyzAppView.h

class ChellogridAppView : public  CCoeControl
{
}

in xyzAppView.cpp


#include <aknutils.h> // for AKN_LAF_COLOR
#include <avkon.hrh>
#include <aknnotewrappers.h>
#include <coemain.h>
#include <BARSREAD.H>
#include <akngrid.h>
#include <eiklabel.h>
#include <AknGridView.h>
#include <aknpopup.h>
#include "hellogrid.rsg"
#include "hellogridAppView.h"

#define LABEL_BACKGROUND_COLOR AKN_LAF_COLOR( 199 )
// ============================ MEMBER FUNCTIONS ===============================

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

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

// -----------------------------------------------------------------------------
// ChellogridAppView::ConstructL()
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void ChellogridAppView::ConstructL( const TRect& aRect )
    {
    // Create a window for this application view
    CreateWindowL();
   
    //SetRect( aRect );
    //ActivateL();
       
    iGrid = new( ELeave ) CAknGrid;
    iGrid->SetContainerWindowL( *this );
TResourceReader reader;
    CEikonEnv::Static()->CreateResourceReaderLC(reader, R_SELECTIONGRID);
    iGrid->ConstructFromResourceL(reader);
    iGrid->ActivateL();
   
    //iGrid->MakeVisible(ETrue);
//iGrid->SetFocus(ETrue);
iGrid->SetFocus(ETrue);
iGrid->DrawNow();
     
    CleanupStack::PopAndDestroy();//reader
   
    // Set the windows size
    SetRect( aRect );

    // Activate the window, which makes it ready to be drawn
    ActivateL();
    }

TInt ChellogridAppView::CountComponentControls() const
    {
    return 1; // return nbr of controls inside this container
    }

// ---------------------------------------------------------
// CFinGeniusContainer::ComponentControl(TInt aIndex) const
// ---------------------------------------------------------
//
CCoeControl* ChellogridAppView::ComponentControl(TInt aIndex) const
    {
    switch ( aIndex )
        {
        case 0:
            return iGrid;
        default:
            return NULL;
        }
    }
   
TKeyResponse ChellogridAppView::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
{
if (aType!=EEventKey)
return EKeyWasNotConsumed;

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

}

// -----------------------------------------------------------------------------
// ChellogridAppView::ChellogridAppView()
// C++ default constructor can NOT contain any code, that might leave.
// -----------------------------------------------------------------------------
//
ChellogridAppView::ChellogridAppView()
    {
    // No implementation required
    }


// -----------------------------------------------------------------------------
// ChellogridAppView::~ChellogridAppView()
// Destructor.
// -----------------------------------------------------------------------------
//
ChellogridAppView::~ChellogridAppView()
    {
    // No implementation required
    }
   

// -----------------------------------------------------------------------------
// ChellogridAppView::Draw()
// Draws the display.
// -----------------------------------------------------------------------------
//
void ChellogridAppView::Draw( const TRect& aRect ) const
    {
    // Get the standard graphics context
    CWindowGc& gc = SystemGc();
    gc.SetPenStyle( CGraphicsContext::ENullPen );
    gc.SetBrushColor( LABEL_BACKGROUND_COLOR );
    gc.SetBrushStyle( CGraphicsContext::ESolidBrush );       
    gc.DrawRect( aRect );
    // Gets the control's extent
    TRect drawRect( Rect());
   
    // Clears the screen
    gc.Clear( drawRect );
   
  }

// -----------------------------------------------------------------------------
// ChellogridAppView::SizeChanged()
// Called by framework when the view size is changed.
// -----------------------------------------------------------------------------
//
void ChellogridAppView::SizeChanged()
    { 
    DrawNow();
    }
// End of File

in .rss
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 = 20;
height = 20;
}

RESOURCE ARRAY r_selectiongrid_items
{
items =
{
LBUF { txt = "Music"; },
LBUF { txt = "Picture"; },
LBUF { txt = "Video"; },
LBUF { txt = "Games"; },
LBUF { txt = "Hi"; },
                                LBUF { txt = "Others"; }

};
}


But it is not showing me anything except scroll bar!!! I havn't use container class.

I think, I have created grid and after that draw method is called which hides my grid. Is that so?

Plz help

Thanx

Meetee

Tue, 2006-06-27 06:22
Joined: 2005-06-01
Forum posts: 76
I think you should try SetExtent() and the following


AknListBoxLayouts::SetupFormGfxCell( *iGrid, iGrid->ItemDrawer(), 0, 0, 0, 0, 0,  100, iGrid->ItemHeight(), TPoint( 0, 0 ), TPoint( 100, iGrid->ItemHeight() ));


..
KiraN Puranik


Wed, 2006-06-28 07:22
Joined: 2006-06-03
Forum posts: 26
Thanx for ur reply Kiran,

By implementing  iGrid->SetExtent(TPoint(70,70),TSize(150, 150)); grid appears:-) , but by using
    AknListBoxLayouts::SetupFormGfxCell( *iGrid, iGrid->ItemDrawer(),0, 0, 0, 0, 0,  100, iGrid->ItemHeight(),
  TPoint( 0, 0 ), TPoint( 100, iGrid->ItemHeight() ));   
() ));    application is closed on emulator! and in grid, text is not dispayed, why so?Sad

plz reply...

Meetee




Wed, 2006-06-28 11:22
Joined: 2006-06-03
Forum posts: 26
hey,

My problem is solved..

Any pointers regarding menu grid?

Thanx

Meetee

copyright 2003-2009 NewLC SARL