×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Dec 2008
    Posts
    20

    Grid Positioning problem??

    hi there,
    i am using EMMC Grid example as a base to my application. the problem is when i change the position of grid to make it in center of the screen. the side from the top left becomes white and doesnt remain transparent. Any Suggestion/// Help plz
    i want it to make the list in center and without any background
    Thanks

    plz follow the link to see the actual screen shot http://www.flickr.com/photos/23711627@N08/3759301056/

    Code:
    ///////////Container file//////////
    
    #define KGridPosition TPoint(50,50)  //// by default value is TPoint (0,0)
    
    void CSimpleGridContainer::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();
    	}
    
    void CSimpleGridContainer::SizeChanged()
    	{
    	
    	if (iGamesGrid)
    		{
    		iGamesGrid->SetExtent (KGridPosition, Rect().Size());
    		}
    	}

  2. #2
    Nokia Developer Champion
    Join Date
    Jan 2008
    Location
    Moscow, Russia
    Posts
    3,348

    Re: Grid Positioning problem??

    If you want to add system background instead white color you can use following code:

    .h
    Code:
    class CAknsBasicBackgroundControlContext;
    
    private: // data
      CAknsBasicBackgroundControlContext*    iBackGround;

    .cpp
    Code:
    #include <aknsbasicbackgroundcontrolcontext.h>
    
    void CSimpleGridContainer::ConstructL(const TRect& aRect)
        {
        ...
        iBackGround = CAknsBasicBackgroundControlContext::NewL(
            KAknsIIDQsnBgAreaMain, Rect(), EFalse);
        ...
        }
        
    
    void CSimpleGridContainer::SizeChanged()
        {
        if (iBackGround)
            {
            iBackGround->SetRect(Rect());
            }
            
        ...
        }
        
    void CSimpleGridContainer::Draw(const TRect& aRect) const
        {
        CWindowGc& gc = SystemGc();
        
        MAknsSkinInstance* skin = AknsUtils::SkinInstance();
        MAknsControlContext* cc = AknsDrawUtils::ControlContext(this);
        AknsDrawUtils::Background(skin, cc, this, gc, aRect);
        
        // Add your drawing code here
        ...
        }
        
    
    TTypeUid::Ptr CSimpleGridContainer::MopSupplyObject(TTypeUid aId)
        {
        if (aId.iUid == MAknsControlContext::ETypeId && iBackGround)
            {
            return MAknsControlContext::SupplyMopObject(aId, iBackGround);
            }
        
        return CCoeControl::MopSupplyObject(aId);
        }
    
    CSimpleGridContainer::~CSimpleGridContainer()
        {
        delete iBackGround;
        }

  3. #3
    Registered User
    Join Date
    Dec 2008
    Posts
    20

    Thumbs up Re: Grid Positioning problem??

    Quote Originally Posted by A.A.M. View Post
    If you want to add system background instead white color you can use following code:

    .h
    Code:
    class CAknsBasicBackgroundControlContext;
    
    private: // data
      CAknsBasicBackgroundControlContext*    iBackGround;

    .cpp
    Code:
    #include <aknsbasicbackgroundcontrolcontext.h>
    
    void CSimpleGridContainer::ConstructL(const TRect& aRect)
        {
        ...
        iBackGround = CAknsBasicBackgroundControlContext::NewL(
            KAknsIIDQsnBgAreaMain, Rect(), EFalse);
        ...
        }
        
    
    void CSimpleGridContainer::SizeChanged()
        {
        if (iBackGround)
            {
            iBackGround->SetRect(Rect());
            }
            
        ...
        }
        
    void CSimpleGridContainer::Draw(const TRect& aRect) const
        {
        CWindowGc& gc = SystemGc();
        
        MAknsSkinInstance* skin = AknsUtils::SkinInstance();
        MAknsControlContext* cc = AknsDrawUtils::ControlContext(this);
        AknsDrawUtils::Background(skin, cc, this, gc, aRect);
        
        // Add your drawing code here
        ...
        }
        
    
    TTypeUid::Ptr CSimpleGridContainer::MopSupplyObject(TTypeUid aId)
        {
        if (aId.iUid == MAknsControlContext::ETypeId && iBackGround)
            {
            return MAknsControlContext::SupplyMopObject(aId, iBackGround);
            }
        
        return CCoeControl::MopSupplyObject(aId);
        }
    
    CSimpleGridContainer::~CSimpleGridContainer()
        {
        delete iBackGround;
        }
    Thanks A.A.M. Code is perfectly fine and my application is now showing the default phone theme and no white background. Thanks again.
    very little thing i want to add to this code is use these header files in .CPP file
    Code:
    #include <AknsDrawUtils.h>
    #include <AknsBasicBackgroundControlContext.h>
    #include <eiklabel.h>
    and declare publicly in header file
    Code:
    TTypeUid::Ptr MopSupplyObject(TTypeUid aId);
    CHEERS

Similar Threads

  1. STLPort namespace issue
    By yickhong in forum Open C/C++
    Replies: 0
    Last Post: 2009-04-09, 08:54
  2. Problem with Grid and ScrollBar
    By mallikachand in forum Symbian User Interface
    Replies: 0
    Last Post: 2008-06-18, 05:50
  3. Replies: 4
    Last Post: 2008-05-22, 08:50
  4. Replies: 0
    Last Post: 2006-04-24, 04:37
  5. Grid and OfferKeyEventL problem.
    By darkenvy in forum Symbian User Interface
    Replies: 2
    Last Post: 2003-02-09, 23:10

Posting Permissions

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