×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    20

    Scrolling down to see the controls drawn outside of ClientRect()!! Is it possible?

    Hi
    I want to draw some controls like CEikEdwin, CEikLabel, CEikSecreted etc.(there may be more than one control of a type). But the controls which are not drawn inside ClientRect(i.e the visible area of the mobile) are not shown.

    Can a scroll bar be put and we can scroll down to see the controls?
    or if any other way to do this.

    Any suggestions are appreciable.

    regards
    Satyajit

  2. #2
    Registered User
    Join Date
    Sep 2005
    Posts
    20

    Re: Scrolling down to see the controls drawn outside of ClientRect()!! Is it possible?

    Hi
    I am explaining my problem once again. I am drawing controls dynamically. The new controls are drawn just vertically below the previous control. So after 6/7 controls the new control is drawn out side of the ClientRect(); i.e. visible area, but it is drawn. So the control is not shown. how can i show these controls?

    Please help me. it is urgent..

    thanx
    Satyajit

  3. #3
    Registered User
    Join Date
    Sep 2005
    Posts
    20

    Re: Scrolling down to see the controls drawn outside of ClientRect()!! Is it possible?

    Hi
    I have drawn alternative Label and edwin controls dynamically. just changing the "noofctrl" to any integer that no of controls are drawn.
    My code is as follows

    The .cpp file
    Code:
    #include <coemain.h>
    #include <eiklabel.h>
    #include <eikedwin.h>
    #include <barsread.h>
    #include <badesca.h>
    #include <eiktxlbm.h>
    
    #include <test.rsg>
    
    #include "testAppview1.h"
    
    // Standard construction sequence
    CtestAppview1* CtestAppview1::NewL(const TRect& aRect)
        {
        CtestAppview1* self = CtestAppview1::NewLC(aRect);
        CleanupStack::Pop(self);
        return self;
        }
    
    CtestAppview1* CtestAppview1::NewLC(const TRect& aRect)
        {
        CtestAppview1* self = new (ELeave) CtestAppview1;
        CleanupStack::PushL(self);
        self->ConstructL(aRect);
        return self;
        }
    
    CtestAppview1::CtestAppview1()
        {
    	// no implementation required
        }
    
    CtestAppview1::~CtestAppview1()
        {
        for(TInt i=0;i<noofctrl;i++)
        	{
        	if(iCtrl[i])
        		{
        		delete iCtrl[i];
        		iCtrl[i]=NULL;
        		}
        	}
    	// no implementation required
        }
    
    void CtestAppview1::ConstructL(const TRect& aRect)
        {
        // Create a window for this application view1
        CreateWindowL();
        noofctrl=2;
        ycord = 5;
    	for(TInt i=0;i<noofctrl;i++)
    		{
    		if(i%2==0)
    			InitializeLabel(&iCtrl[i]);
    		else
    			InitializeEdwin(&iCtrl[i]);
    		}
    	iCtrl[1]->SetFocus(ETrue);
        // Set the windows size
        SetRect(aRect);
    
        // Activate the window, which makes it ready to be drawn
        ActivateL();
        }
    
    // Draw this application's view1 to the screen
    void CtestAppview1::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 );
        }
    void CtestAppview1::SizeChanged()
        {
        // TODO: Add here control resize code etc.
        }
    TInt CtestAppview1::CountComponentControls() const
        {
        return noofctrl; // return nbr of controls inside this container
        }
    
    CCoeControl* CtestAppview1::ComponentControl(TInt aIndex) const
        {
        if(aIndex >= 0 && aIndex < noofctrl)
        	return iCtrl[aIndex];
        else
        	return NULL;
        }
    
    TKeyResponse CtestAppview1::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
    {
    	for(TInt i=1;i<noofctrl;i+=2)
    		{
    		if(iCtrl[i]->IsFocused())
    			{
    			if(aKeyEvent.iCode == EKeyDownArrow)
    				{
    				if((i+2)<noofctrl)
    					{
    					iCtrl[i]->SetFocus(EFalse);
    					iCtrl[i+2]->SetFocus(ETrue);
    					}
    				}
    			if(aKeyEvent.iCode == EKeyUpArrow)
    				{
    				if((i-2)>0)
    					{
    					iCtrl[i]->SetFocus(EFalse);
    					iCtrl[i-2]->SetFocus(ETrue);
    					}
    				}
    			return iCtrl[i]->OfferKeyEventL(aKeyEvent,aType);	
    			}
    		}
        return EKeyWasNotConsumed;
    }
    
    void CtestAppview1::InitializeLabel(CCoeControl** iLabel)
    	{
        *iLabel = new (ELeave) CEikLabel;
        (*iLabel)->SetContainerWindowL( *this );
        ((CEikLabel*)*iLabel)->SetTextL( _L("Label") );
        (*iLabel)->SetExtent( TPoint(10,ycord), (*iLabel)->MinimumSize() );
        ycord+=(*iLabel)->Size().iHeight+5;
    	}
    
    void CtestAppview1::InitializeEdwin(CCoeControl** iText)
    	{
    	TResourceReader reader;
        iCoeEnv->CreateResourceReaderLC(reader, R_EDWIN);
    	*iText = new (ELeave) CEikEdwin;
    	(*iText)->SetContainerWindowL( *this );
        (*iText)->ConstructFromResourceL(reader);
    	CleanupStack::PopAndDestroy();  // Resource reader
    	(*iText)->SetExtent(TPoint(10,ycord), (*iText)->MinimumSize());
    	ycord+=(*iText)->Size().iHeight+5;
    	}
    the .h file
    Code:
    #ifndef __TEST_APPVIEW1_H__
    #define __TEST_APPVIEW1_H__
    
    
    #include <coecntrl.h>
    
    class CtestAppview1 : public CCoeControl
        {
    public:
    
        static CtestAppview1* NewL(const TRect& aRect);
        static CtestAppview1* NewLC(const TRect& aRect);
    
    	 ~CtestAppview1();
    public:  // from CCoeControl
        void Draw(const TRect& aRect) const;
      
    private: // Functions from base classes
    
        void SizeChanged();
        TInt CountComponentControls() const;
        CCoeControl* ComponentControl(TInt aIndex) const;
    	TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
    	void InitializeLabel(CCoeControl** iLabel);
    	void InitializeEdwin(CCoeControl** iText);
    public:
        void ConstructL(const TRect& aRect);
        CtestAppview1();
    private:
        CCoeControl* iCtrl[10];
        TInt noofctrl,ycord;
        };
    
    
    #endif // __TEST_APPview1_H__
    the problem is after the 3rd text box is drawn the next controls are drawn outside of the ClientRect and is not visible.
    how to make those controls visible. Is some scrollbar can put to view those?
    Is there any other way?
    and also is there any easier way to draw dynamic controls?

    Please help me
    it is most urgent

    thanx
    Satyajit

  4. #4
    Regular Contributor
    Join Date
    Jul 2004
    Posts
    273

    Re: Scrolling down to see the controls drawn outside of ClientRect()!! Is it possible?

    Is there a solution?

    i am facing the same problem

  5. #5
    Regular Contributor
    Join Date
    Nov 2004
    Location
    Mumbai - India
    Posts
    155

    Re: Scrolling down to see the controls drawn outside of ClientRect()!! Is it possible?

    I solved it just by updating position of controls n showing scrollbar. I mean

    for(i....)
    CCoeControl* Ctrl = ComponentControl(i);
    Ctrl->SetPosition(TPoint(Ctrl->Position().iX, Ctrl->Position().iY (+/-) aShift));



    saur

  6. #6
    Super Contributor
    Join Date
    May 2005
    Location
    Hyderabad,India
    Posts
    704

    Re: Scrolling down to see the controls drawn outside of ClientRect()!! Is it possible?

    Hi,

    have changed the CountComponentControlsL()

    regards,
    eswar

  7. #7
    Regular Contributor
    Join Date
    Mar 2005
    Location
    Mumbai
    Posts
    212

    Re: Scrolling down to see the controls drawn outside of ClientRect()!! Is it possible

    Hi Saurab and Eswar,

    Could you explain this in detail. I mean at what point do you scroll. Suppose there are a sequence of labels and edwins, in which a few go off the screen. At what point do you user SetPosition. What is the purpose of the for loop.

    In case of 3rd Edition the label may/maynot span multiple lines because of different resolutions, how will this be taken care of.

    Thanks in advance
    Avi

  8. #8
    Regular Contributor
    Join Date
    Nov 2004
    Location
    Mumbai - India
    Posts
    155

    Re: Scrolling down to see the controls drawn outside of ClientRect()!! Is it possible?

    so simplest way to understand is :

    Initially Set control positions, as container height is infinite. after calling Setposition/setextent on last control u will get to know, how much height u require for container.

    Lets considr I hv 35 ctrls. after giving position to all of them, I found I require container ht. 1130 pixels. I set container ht = 1132.

    Now when user scrolls. After setting focus to desired ctrl, I call updatePosition
    which updates container position(no need to use for loop).

    UpdatePosition(ctrl) // ctrl is currently focussed ctrl
    {
    TInt difference = (aCtrl->Position().iY + aCtrl->Size().iHeight + 2) - Position().iY;

    TRect rect;
    rect = Rect();
    if(difference >= Size().iHeight )
    {
    TInt requiredPosition = Size().iHeight - difference;
    SetPosition( TPoint(0, requiredPosition) );

    }
    else
    {
    SetPosition( TPoint(0, 0) );
    }

    }

    [as soon as focus will go to ctrl outside container it will set containr position in some -ve pos. and ur ctl will come on screen. ]

    saurabh

  9. #9
    Regular Contributor
    Join Date
    Mar 2005
    Location
    Mumbai
    Posts
    212

    Re: Scrolling down to see the controls drawn outside of ClientRect()!! Is it possible

    Gr8 explaination Saurabh,

    So a check is made everytime in offerkeyevent for the focus & height , depending on which UpdatePosition is called.

    Ok , trying it out right now. Will get back if any issues.

    Thanks.

Similar Threads

  1. Custom controls or extend existing controls?
    By mayur_24 in forum Symbian User Interface
    Replies: 2
    Last Post: 2007-10-05, 16:16
  2. dynamic controls in containers
    By entell in forum Symbian
    Replies: 5
    Last Post: 2005-02-18, 18:11
  3. How to set which Compound Control gets drawn?
    By Subotai4Winds in forum Symbian
    Replies: 2
    Last Post: 2005-02-02, 14:26
  4. Repositioning controls in CEikDialog::PreLayoutDynInitL()
    By gpalvia in forum Symbian User Interface
    Replies: 3
    Last Post: 2004-03-11, 02:37
  5. drawing composite controls within CListItemDrawer::DrawActual Item
    By joshd29 in forum Symbian User Interface
    Replies: 1
    Last Post: 2003-08-09, 00:41

Posting Permissions

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