×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    Sep 2008
    Posts
    110

    Question Controls do not draw ,NeedHelp

    I am having some controls contained in a container instances of the following class.
    Code:
    #include "hdrandfooter/CBand.h"
    #include <coemain.h>
    #include <EMail.mbg>
    
    CBand::CBand(TInt aBandType,MStateObserver& aStateObserver,MImageLoader& aImageLoader)
    :iStateObserver(aStateObserver),iImageLoader(aImageLoader)
    	{
    		iBandType=aBandType;
    	}
    
    CBand::~CBand()
    	{
    	
    	}
    void CBand::ConstructL()
    	{
    	CreateWindowL();
    	TRect iRect=TRect();
    	switch(iBandType)
    	{
    		case KBandHeader:
    		iRect.iTl.iX=0;
    		iRect.iTl.iY=0;
    		iRect.iBr.iX=iImageLoader.GetClientScreen().iBr.iX;
    		iRect.iBr.iY=CCoeEnv::Static()->NormalFont()->HeightInPixels();
    		break;
    		case KBandFooter:
    		iRect.iTl.iX=0;
    		iRect.iTl.iY=iImageLoader.GetFullScreen().iBr.iY-CCoeEnv::Static()->NormalFont()->HeightInPixels();
    		iRect.iBr.iX=iImageLoader.GetClientScreen().iBr.iX;
    		iRect.iBr.iY=iImageLoader.GetFullScreen().iBr.iY;
    		break;
    	}
    	SetRect(iRect);
    	ActivateL();
    	}
    void CBand::Draw(const TRect aRect)const
    	{
    		CWindowGc& gc=SystemGc();
    		gc.DrawBitmap(aRect,iImageLoader.GetImage(EMbmEmailTopper));
    	
    	}
    and the are called into the container as
    Code:
    void CEMailContainer::ConstructL()
    	{
    	iHeader=new (ELeave) CBand(CBand::KBandHeader,iStateObserver,iImageLoader);
    	iHeader->SetMopParent(this);
    	iHeader->ConstructL();
    	iFooter=new (ELeave) CBand(CBand::KBandFooter,iStateObserver,iImageLoader);
    	iFooter->SetMopParent(this);
    	iFooter->ConstructL();
    	iOption=new (ELeave) COptionScreen(iStateObserver,iImageLoader);
    	iOption->SetMopParent(this);
    	iOption->ConstructL();
    
    	iHeader->DrawNow();
    	iFooter->DrawNow();
    	iOption->DrawNow();
    
    	ActivateL();
    	}
    TInt CEMailContainer::CountComponentControls() const
    	{
    	return 3; // return nbr of controls inside this container
    	}
    
    // ---------------------------------------------------------
    // CEMailContainer::ComponentControl(TInt aIndex) const
    // ---------------------------------------------------------
    //
    CCoeControl* CEMailContainer::ComponentControl(TInt aIndex) const
    	{
    	switch ( aIndex )
    		{
    		case 0:
    			return iHeader;
    		case 1:
    			return iFooter;
    		case 2:
    		    return iOption;
    		default:
    			return NULL;
    		}
    	}
    But my code does not enter the draw function of the iHeader ,iFooter and iOption .

  2. #2
    Super Contributor
    Join Date
    Jul 2008
    Location
    Chennai,India
    Posts
    889

    Re: Controls do not draw ,NeedHelp

    Have you checked with the debugger, whether the controls are created r not..
    Is your CBand a CCoeControl..

  3. #3
    Registered User
    Join Date
    Sep 2008
    Posts
    110

    Re: Controls do not draw ,NeedHelp

    Yes the controls are being created and yes of course CBand inherits CCoeControl as public .. Also I have seen that my debug pointer goes into relevant lines in ComponentControls of the container once in top to bottom oder and once bottom up order . Strange ?

  4. #4
    Super Contributor
    Join Date
    Jul 2008
    Location
    Chennai,India
    Posts
    889

    Re: Controls do not draw ,NeedHelp

    Have you added ur control to the stack..
    Also check if CBand's Draw is called..
    Make sure u call ActivateL() first and then Draw().
    Anyway have a look at the following link...
    http://wiki.forum.nokia.com/index.ph...Custom_control

    find if anything is missing..

  5. #5
    Registered User
    Join Date
    Sep 2008
    Posts
    110

    Re: Controls do not draw ,NeedHelp

    Yes , I have added the container to the control stack . The controls are in the container , do I have to add each of them into the stack ? In which order ? Since , if I create and add them in the ConstructL . The top content in the stack would be the container itself , without window .
    Secondly , before calling Drawnow for control objects I have called respective Activatel in their constructor . Do I have to call the caontainer ActivateL before calling Drawnow for contained Controls?

    Code:
    void CEMailAppUi::DeleteSplash()
    	{
    	RemoveFromStack(iSplashScreen);
    	AddToStackL( iAppContainer );
    	if(iSplashScreen != (CSplashScreen *)NULL)
    		{
    			delete iSplashScreen;
    			iSplashScreen = (CSplashScreen *)NULL;
    		}	
    	}
    void CEMailAppUi::CreateHomeScreen()
    	{
    	iAppContainer = new (ELeave) CEMailContainer(*this,*this);//::NewL(*this,*this,this);
    	iAppContainer->SetMopParent(this);
    	iAppContainer->ConstructL(this);
    	DeleteSplash();	
    	}
    Last edited by sudeepa2005; 2008-12-19 at 07:08.

  6. #6
    Super Contributor
    Join Date
    Mar 2004
    Location
    Czech Republic
    Posts
    2,037

    Re: Controls do not draw ,NeedHelp

    Hi,

    I have 2 questions

    1/ Is CEMailContainer CCoeControl derived? I gues it is as you implement CountComponentControls() and ComponentControl().

    2/ Where is the window specified for the container - you have to call either CreateWindowL() or SetContainerWindowL().

    3/ Where do you set the rectange for the container?

    BR
    STeN

  7. #7
    Registered User
    Join Date
    Sep 2008
    Posts
    110

    Re: Controls do not draw ,NeedHelp

    Yes Stenlik. My Container is a control , Well in one version I made it windowless (as I read somewhere that windows must be declared for the topmost level controls ) . Now in this windowless Container I tried to make the Control windows appear . That was the code but none was drawing . No Container , No Control.
    In the second version I tried creating one window for the Container and pass that one to my contained control . The funny thing is that , in the second case , if I implement draw codes into my container that 1 is getting executed and not the Controls draw codes .
    My code is
    Code:
    void CEMailContainer::ConstructL(MObjectProvider* /*aParent*/)
    	{
    	/* if we create a window in the container and pass them
    	 * there is a resource lock occuring , ie iHeader is locking window
    	 * so that one cannot be used by others to draw */
    	CreateWindowL(); 	
    	SetRect(iImageLoader.GetFullScreen());
    	iHeader=new (ELeave) CBand(CBand::KBandHeader,iStateObserver,iImageLoader);
    	CleanupStack::PushL(iHeader);
    //	iHeader->SetMopParent(this);//Header contains window
    	iHeader->SetContainerWindowL(*this);
    	iHeader->ConstructL();
    	CleanupStack::Pop(iHeader);
    	CEikonEnv::Static()->EikAppUi()->AddToStackL(iHeader);	
    	iFooter=new (ELeave) CBand(CBand::KBandFooter,iStateObserver,iImageLoader);
    	CleanupStack::PushL(iFooter);
    //	iFooter->SetMopParent(this);
    	iFooter->SetContainerWindowL(*this);
    	iFooter->ConstructL();
    	CleanupStack::Pop(iFooter);
    	iOption=new (ELeave) COptionScreen(iStateObserver,iImageLoader);
    	CleanupStack::PushL(iOption);
    //	iOption->SetMopParent(this);
    	iOption->SetContainerWindowL(*this);
    	iOption->ConstructL();
    	CleanupStack::Pop(iOption);
    //	iFooter=CBand::NewL(CBand::KBandFooter,iStateObserver,iImageLoader,this);	
    	iHeader->DrawNow();
    	iFooter->DrawNow();
    	iOption->DrawNow();	
    	ActivateL();
    	}
    
    void CEMailContainer::Draw(const TRect& aRect) const
    	{
    	CWindowGc& gc = SystemGc();
    	// TODO: Add your drawing code here
    	// example code...
    	gc.SetPenStyle( CGraphicsContext::ENullPen );
    	gc.SetBrushColor( KRgbGray );
    	gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
    	gc.DrawRect( aRect );
    	}
    If I combine a windowed Container with windowed Control and execute draw codes in both , I can see Container window being drawn with a big rectangular hole in it , where the control should lie . . what should I do ?
    Last edited by sudeepa2005; 2008-12-19 at 07:41.

  8. #8
    Registered User
    Join Date
    Sep 2008
    Posts
    110

    Talking Re: Controls do not draw ,NeedHelp

    Solved ,but is it always only one control and its respective container would be locking server for draw code ? Can we not impose draw for multiple samelevel controls ?

  9. #9
    Super Contributor
    Join Date
    Mar 2004
    Location
    Czech Republic
    Posts
    2,037

    Re: Controls do not draw ,NeedHelp

    Hi,

    in the compound control (container) can be included many controls - there are no limits for that. Check following link about how to implement properly the custom control:

    http://wiki.forum.nokia.com/index.ph...Custom_control

    BR
    STeN

Similar Threads

  1. Replies: 0
    Last Post: 2008-05-17, 08:52
  2. why can i not draw line in Draw()?
    By isarc in forum Symbian
    Replies: 7
    Last Post: 2008-05-13, 10:51
  3. can i draw png icon on controls
    By JackSu in forum Symbian User Interface
    Replies: 4
    Last Post: 2007-08-22, 10:19
  4. Draw controls in a thread.
    By deercrane in forum Symbian
    Replies: 6
    Last Post: 2007-03-28, 12:58
  5. How can I draw the controls?
    By hydlx in forum Symbian Tools & SDKs
    Replies: 2
    Last Post: 2006-06-19, 12:04

Posting Permissions

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